Track the fixed PhotoCraft source baseline with the existing native client integration. Use the actual Pi SDK for normal sends, durable session recovery, demand-loaded enterprise rules and checked undoable canvas tools. Retain request identities and never resend unknown inference. Include local packaging and real-call acceptance evidence.
24 lines
1.6 KiB
JavaScript
24 lines
1.6 KiB
JavaScript
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import assert from 'node:assert/strict';
|
|
import { Native98kBroker } from '../src/native-bridge.mjs';
|
|
import { ProjectStore, atomic } from '../src/store.mjs';
|
|
import { DetailPiAgent } from '../src/agent.mjs';
|
|
const config = JSON.parse(await fs.readFile(process.argv[2], 'utf8'));
|
|
const broker = new Native98kBroker(config.broker), info = await broker.info();
|
|
const store = await ProjectStore.open(config.output, { scope: info.accountScope, project: config.broker.project }, config.binding);
|
|
const dir = path.join(config.broker.profile, 'jiansun/accounts', info.accountScope, 'pi-validation', config.broker.project, 'requests');
|
|
const before = (await fs.readdir(dir)).sort();
|
|
const host = await DetailPiAgent.open({ store, broker, protocolMode: 'native-tools' });
|
|
try {
|
|
const known = await host.recover('61616ad2-b1d4-4281-a63e-32a60876c5e2');
|
|
assert.equal(known.alreadyApplied, true); assert.equal(known.reposted, false);
|
|
const unknown = await host.recover('0447b17b-1c45-4902-a6a5-18357a3e2a3f');
|
|
assert.equal(unknown.phase, 'unknown'); assert.equal(unknown.reposted, false);
|
|
await assert.rejects(host.prompt('核查阻止重复发送的保护,不应真的发给模型'), /未知请求/);
|
|
const after = (await fs.readdir(dir)).sort(); assert.deepEqual(after, before);
|
|
const result = { known, unknown, newPromptBlocked: true, dispatchReceiptsBefore: before.length, dispatchReceiptsAfter: after.length, checkedAt: new Date().toISOString() };
|
|
await atomic(path.join(config.output, 'readonly-recovery.json'), result);
|
|
console.log(JSON.stringify(result, null, 2));
|
|
} finally { await host.dispose(); }
|