Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/edge/src/edge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ describe('edge API', () => {
expect(skillInvokeCanRunAfterBootstrap('initialized', bootstrapComplete)).toBe(true);
});

it('allows agents whose persistent deployment is already active after Edge restart', () => {
expect(skillInvokeCanRunAfterBootstrap('activating', false, 'active')).toBe(true);
});

it('serves health, docs, quote, settle, auth-gated agent, memory, receipt, and refund routes', async () => {
const app = buildEdgeServer({ chainClient: new FakeChain(), storageClient: new FakeStorage(), signerKey, chainId: 16602, paymentRouterAddress: address, receiptBookAddress: address, jwtSecret: 'test-secret' });
await app.ready();
Expand Down
6 changes: 3 additions & 3 deletions apps/edge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export const skillInvokeBootstrapComplete = (
installedSkillIds: Set<string>,
): boolean => onboarding?.status === 'complete' || (deploymentSelectedIds.length > 0 && deploymentSelectedIds.every((id) => installedSkillIds.has(id)));

export const skillInvokeCanRunAfterBootstrap = (status: AgentRecord['status'], bootstrapComplete: boolean): boolean =>
status === 'active' || ((status === 'initialized' || status === 'ready') && bootstrapComplete);
export const skillInvokeCanRunAfterBootstrap = (status: AgentRecord['status'], bootstrapComplete: boolean, deploymentStatus?: DeploymentRecord['status']): boolean =>
status === 'active' || deploymentStatus === 'active' || ((status === 'initialized' || status === 'ready') && bootstrapComplete);

const LIVE_SKILL_IDS = new Set(['chat.completion', 'code.review', 'text.entities', 'text.sentiment', 'text.summarize', 'text.translate']);
const skillInvokeParamsSchema = z.object({ skillId: z.enum(['chat.completion', 'code.review', 'text.entities', 'text.sentiment', 'text.summarize', 'text.translate']) });
Expand Down Expand Up @@ -2201,7 +2201,7 @@ export function buildEdgeServer(options: EdgeServerOptions): FastifyInstance {
// hydrated on Edge restart. The legacy in-memory check is kept as
// an OR fallback for agents that may pre-date onboarding tracking.
const bootstrapComplete = skillInvokeBootstrapComplete(onboarding, deploymentSelectedIds, installedSkillIds);
const canRunAfterBootstrap = skillInvokeCanRunAfterBootstrap(agent.status, bootstrapComplete);
const canRunAfterBootstrap = skillInvokeCanRunAfterBootstrap(agent.status, bootstrapComplete, deployment?.status);
if (!canRunAfterBootstrap) return problem(reply, 409, 'Activation in progress', 'This agent is not bootstrapped yet. Wait for activation to finish before running skills.');
const policy = deployment?.policy;
const allowed = new Set([...(policy?.allowedSkills ?? []), ...(policy?.allowedActions ?? [])]);
Expand Down
Loading