@roj-ai/sdk 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -60,7 +60,8 @@ export { ChatMessageId } from './plugins/user-chat/schema.js';
60
60
  export type { AskUserInputType, AskUserInputTypeSchema, AskUserOption } from './plugins/user-chat/schema.js';
61
61
  export type { BuiltinEvent } from './builtin-events.js';
62
62
  export type { AgentChatMessage, AskUserChatMessage, ChatMessage, UserChatMessage } from './plugins/user-chat/index.js';
63
- export { agentStatusPlugin } from './plugins/agent-status/plugin.js';
63
+ export { agentStatusPlugin, agentStoppedNotificationSchema } from './plugins/agent-status/plugin.js';
64
+ export type { AgentStoppedNotification } from './plugins/agent-status/plugin.js';
64
65
  export { agentsPlugin } from './plugins/agents/plugin.js';
65
66
  export type { AgentsPluginConfig } from './plugins/agents/plugin.js';
66
67
  export { contextCompactPlugin } from './plugins/context-compact/plugin.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACxD,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGzC,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACpE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAGnE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1F,YAAY,EAAE,oBAAoB,EAAE,gB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GrF,YAAY,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAA;AAIhF,YAAY,EACX,YAAY,EACZ,MAAM,EACN,eAAe,EACf,cAAc,EACd,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,KAAK,GACL,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ export { getAgentMailbox, selectMailboxState } from './plugins/mailbox/query.js'
40
40
  export { MessageId } from './plugins/mailbox/schema.js';
41
41
  export { ChatMessageId } from './plugins/user-chat/schema.js';
42
42
  // Plugins
43
- export { agentStatusPlugin } from './plugins/agent-status/plugin.js';
43
+ export { agentStatusPlugin, agentStoppedNotificationSchema } from './plugins/agent-status/plugin.js';
44
44
  export { agentsPlugin } from './plugins/agents/plugin.js';
45
45
  export { contextCompactPlugin } from './plugins/context-compact/plugin.js';
46
46
  export { limitsGuardPlugin, selectAgentCounters, sumSessionSpend } from './plugins/limits-guard/plugin.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,SAAS;AACT,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGxD,YAAY;AACZ,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAGpE,SAAS;AACT,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAG/C,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1F,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAIjE,cAAc;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAG/C,qBAAqB;AAC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O,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAI5E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAOpE,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAEpG,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAG9D,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAInE,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAG/D,gDAAgD;AAChD,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAErC,mBAAmB;AACnB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAA;AAM/C,iBAAiB;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent-status.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-status.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent-status/agent-status.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,136 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { AgentId } from '../../core/agents/schema.js';
3
+ import { MockLLMProvider } from '../../core/llm/mock.js';
4
+ import { ToolCallId } from '../../core/tools/schema.js';
5
+ import { limitsGuardPlugin } from '../../plugins/limits-guard/plugin.js';
6
+ import { createMultiAgentPreset, createTestPreset, TestHarness } from '../../testing/index.js';
7
+ import { agentStatusPlugin } from './plugin.js';
8
+ const agentStatusNotifications = (session) => session.getNotifications()
9
+ .filter((n) => n.pluginName === 'agent-status' && n.type === 'agentStatus')
10
+ .map((n) => n.payload);
11
+ const agentStoppedNotifications = (session) => session.getNotifications()
12
+ .filter((n) => n.pluginName === 'agent-status' && n.type === 'agentStopped')
13
+ .map((n) => n.payload);
14
+ async function waitForAgentStatus(session, agentId, status, timeoutMs = 5000) {
15
+ const deadline = Date.now() + timeoutMs;
16
+ while (Date.now() < deadline) {
17
+ const agentState = session.state.agents.get(agentId);
18
+ if (agentState?.status === status)
19
+ return;
20
+ await new Promise((r) => setTimeout(r, 10));
21
+ }
22
+ throw new Error(`waitForAgentStatus timed out after ${timeoutMs}ms (wanted ${status}) for agent ${agentId}`);
23
+ }
24
+ describe('agent-status plugin', () => {
25
+ describe('agentStatus (existing behavior)', () => {
26
+ it('emits thinking on start and idle on completion', async () => {
27
+ const harness = new TestHarness({
28
+ presets: [createTestPreset()],
29
+ systemPlugins: [agentStatusPlugin],
30
+ llmProvider: MockLLMProvider.withFixedResponse({ content: 'Done', toolCalls: [] }),
31
+ });
32
+ const session = await harness.createSession('test');
33
+ const entryAgentId = session.getEntryAgentId();
34
+ await session.sendAndWaitForIdle('Hello');
35
+ const statuses = agentStatusNotifications(session).map((p) => p.status);
36
+ expect(statuses).toContain('thinking');
37
+ expect(statuses).toContain('idle');
38
+ // No abnormal-terminal notification for a normal completion.
39
+ expect(agentStoppedNotifications(session)).toHaveLength(0);
40
+ await harness.shutdown();
41
+ });
42
+ });
43
+ describe('agentStopped on pause', () => {
44
+ it('manual pause → agentStopped kind:paused reason:manual with message', async () => {
45
+ let orchestratorCalls = 0;
46
+ const harness = new TestHarness({
47
+ presets: [createMultiAgentPreset([{ name: 'worker', system: 'Worker agent.', tools: [], agents: [] }], { orchestratorSystem: 'Orchestrator agent.' })],
48
+ systemPlugins: [agentStatusPlugin],
49
+ mockHandler: (request) => {
50
+ if (request.systemPrompt.includes('Orchestrator')) {
51
+ orchestratorCalls++;
52
+ if (orchestratorCalls === 1) {
53
+ return {
54
+ content: null,
55
+ toolCalls: [{ id: ToolCallId('tc1'), name: 'start_worker', input: { message: 'Work' } }],
56
+ finishReason: 'stop',
57
+ metrics: MockLLMProvider.defaultMetrics(),
58
+ };
59
+ }
60
+ return { content: 'Done', toolCalls: [], finishReason: 'stop', metrics: MockLLMProvider.defaultMetrics() };
61
+ }
62
+ return { content: 'Worker done', toolCalls: [], finishReason: 'stop', metrics: MockLLMProvider.defaultMetrics() };
63
+ },
64
+ });
65
+ const session = await harness.createSession('test');
66
+ await session.sendAndWaitForIdle('Start');
67
+ // Manual pause via Session.pauseAgent — the real manual-pause API that
68
+ // runs onPause hooks (agents.pause only emits the event, no hooks).
69
+ const innerSession = session.session;
70
+ const result = await innerSession.pauseAgent(AgentId('worker_1'), 'Pausing for review');
71
+ expect(result.ok).toBe(true);
72
+ const stopped = agentStoppedNotifications(session).filter((n) => n.agentId === 'worker_1');
73
+ expect(stopped).toHaveLength(1);
74
+ expect(stopped[0].kind).toBe('paused');
75
+ expect(stopped[0].reason).toBe('manual');
76
+ expect(stopped[0].message).toBe('Pausing for review');
77
+ expect(stopped[0].definitionName).toBe('worker');
78
+ expect(typeof stopped[0].timestamp).toBe('number');
79
+ // idle agentStatus still emitted alongside.
80
+ expect(agentStatusNotifications(session).some((p) => p.agentId === 'worker_1' && p.status === 'idle')).toBe(true);
81
+ await harness.shutdown();
82
+ });
83
+ it('limits-guard hard limit → agentStopped kind:paused with reason and message', async () => {
84
+ let inferenceCount = 0;
85
+ const harness = new TestHarness({
86
+ presets: [createTestPreset({
87
+ orchestratorSystem: 'Test agent.',
88
+ orchestratorPlugins: [limitsGuardPlugin.configureAgent({ limits: { maxTurns: 2 } })],
89
+ })],
90
+ systemPlugins: [agentStatusPlugin, limitsGuardPlugin],
91
+ mockHandler: () => {
92
+ inferenceCount++;
93
+ return {
94
+ content: null,
95
+ toolCalls: [{ id: ToolCallId(`tc${inferenceCount}`), name: 'tell_user', input: { message: `Turn ${inferenceCount}` } }],
96
+ finishReason: 'stop',
97
+ metrics: MockLLMProvider.defaultMetrics(),
98
+ };
99
+ },
100
+ });
101
+ const session = await harness.createSession('test');
102
+ const entryAgentId = session.getEntryAgentId();
103
+ await session.sendMessage('Start');
104
+ await waitForAgentStatus(session, entryAgentId, 'paused');
105
+ const stopped = agentStoppedNotifications(session).filter((n) => n.agentId === String(entryAgentId));
106
+ expect(stopped.length).toBeGreaterThanOrEqual(1);
107
+ expect(stopped[0].kind).toBe('paused');
108
+ // limits-guard pauses via beforeInference {action:'pause'} → reason 'handler',
109
+ // with the human-readable budget detail in `message`.
110
+ expect(stopped[0].reason).toBe('handler');
111
+ expect(stopped[0].message).toBeTruthy();
112
+ await harness.shutdown();
113
+ });
114
+ });
115
+ describe('agentStopped on error', () => {
116
+ it('non-retryable LLM error → agentStopped kind:errored with message', async () => {
117
+ const harness = new TestHarness({
118
+ presets: [createTestPreset()],
119
+ systemPlugins: [agentStatusPlugin],
120
+ llmProvider: MockLLMProvider.withError({ type: 'invalid_request', message: 'Bad request' }),
121
+ });
122
+ const session = await harness.createSession('test');
123
+ const entryAgentId = session.getEntryAgentId();
124
+ await session.sendMessage('Trigger error');
125
+ await waitForAgentStatus(session, entryAgentId, 'errored');
126
+ const stopped = agentStoppedNotifications(session).filter((n) => n.agentId === String(entryAgentId));
127
+ expect(stopped).toHaveLength(1);
128
+ expect(stopped[0].kind).toBe('errored');
129
+ expect(stopped[0].reason).toBeUndefined();
130
+ expect(stopped[0].message).toBe('Bad request');
131
+ expect(stopped[0].definitionName).toBeDefined();
132
+ await harness.shutdown();
133
+ });
134
+ });
135
+ });
136
+ //# sourceMappingURL=agent-status.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-status.test.js","sourceRoot":"","sources":["../../../src/plugins/agent-status/agent-status.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;A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AAY,EAAE,SAAS,CAAC,CAAA;YAE1D,MAAM,OAAO,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;YACpG,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;YAC/B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACvC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAA;YACzC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;YAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAA;YAE/C,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;QACzB,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -14,6 +14,33 @@
14
14
  * `idle` fires on `onComplete`, `onError`, and `onPause` — covers every terminal
15
15
  * state of an agent turn, including hard-limit pauses (limits-guard) and manual
16
16
  * `Session.pauseAgent` calls that would otherwise leave the indicator hung.
17
+ *
18
+ * Alongside the `idle` status, abnormal terminal states (pause / error) also emit
19
+ * a dedicated `agentStopped` notification carrying the pause reason / error detail,
20
+ * so consumers (e.g. a Cloudflare worker) can alert on a budget pause or crash —
21
+ * which the coarse `idle` status alone can't distinguish from a normal completion.
22
+ */
23
+ import z from 'zod/v4';
24
+ /**
25
+ * Payload for the `agentStopped` notification — emitted when an agent reaches an
26
+ * abnormal terminal state (paused or errored), as opposed to a normal idle.
17
27
  */
28
+ export declare const agentStoppedNotificationSchema: z.ZodObject<{
29
+ sessionId: z.core.$ZodBranded<z.ZodString, "SessionId", "out">;
30
+ agentId: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
31
+ definitionName: z.ZodOptional<z.ZodString>;
32
+ kind: z.ZodEnum<{
33
+ errored: "errored";
34
+ paused: "paused";
35
+ }>;
36
+ reason: z.ZodOptional<z.ZodEnum<{
37
+ limit: "limit";
38
+ handler: "handler";
39
+ manual: "manual";
40
+ }>>;
41
+ message: z.ZodOptional<z.ZodString>;
42
+ timestamp: z.ZodNumber;
43
+ }, z.core.$strip>;
44
+ export type AgentStoppedNotification = z.infer<typeof agentStoppedNotificationSchema>;
18
45
  export declare const agentStatusPlugin: import("../../core/plugins/index.js").PluginDefinition<"agent-status", void, void, {}, {}>;
19
46
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent-status/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,eAAO,MAAM,iBAAiB,wFA4ErB,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent-status/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,CAAC,MAAM,QAAQ,CAAA;AAKtB;;;GAGG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;iBAUzC,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAErF,eAAO,MAAM,iBAAiB,wFAsGrB,CAAA"}
@@ -14,11 +14,31 @@
14
14
  * `idle` fires on `onComplete`, `onError`, and `onPause` — covers every terminal
15
15
  * state of an agent turn, including hard-limit pauses (limits-guard) and manual
16
16
  * `Session.pauseAgent` calls that would otherwise leave the indicator hung.
17
+ *
18
+ * Alongside the `idle` status, abnormal terminal states (pause / error) also emit
19
+ * a dedicated `agentStopped` notification carrying the pause reason / error detail,
20
+ * so consumers (e.g. a Cloudflare worker) can alert on a budget pause or crash —
21
+ * which the coarse `idle` status alone can't distinguish from a normal completion.
17
22
  */
18
23
  import z from 'zod/v4';
19
24
  import { agentIdSchema, protocolAgentStatusSchema } from '../../core/agents/schema.js';
20
25
  import { definePlugin } from '../../core/plugins/index.js';
21
26
  import { sessionIdSchema } from '../../core/sessions/schema.js';
27
+ /**
28
+ * Payload for the `agentStopped` notification — emitted when an agent reaches an
29
+ * abnormal terminal state (paused or errored), as opposed to a normal idle.
30
+ */
31
+ export const agentStoppedNotificationSchema = z.object({
32
+ sessionId: sessionIdSchema,
33
+ agentId: agentIdSchema,
34
+ definitionName: z.string().optional(),
35
+ kind: z.enum(['paused', 'errored']),
36
+ /** Present when kind === 'paused' — why the agent was paused. */
37
+ reason: z.enum(['limit', 'handler', 'manual']).optional(),
38
+ /** Human-readable detail (budget message / error message). */
39
+ message: z.string().optional(),
40
+ timestamp: z.number(),
41
+ });
22
42
  export const agentStatusPlugin = definePlugin('agent-status')
23
43
  .notification('agentStatus', {
24
44
  schema: z.object({
@@ -28,6 +48,9 @@ export const agentStatusPlugin = definePlugin('agent-status')
28
48
  definitionName: z.string().optional(),
29
49
  timestamp: z.number(),
30
50
  }),
51
+ })
52
+ .notification('agentStopped', {
53
+ schema: agentStoppedNotificationSchema,
31
54
  })
32
55
  .hook('onStart', async (ctx) => {
33
56
  ctx.notify('agentStatus', {
@@ -80,6 +103,15 @@ export const agentStatusPlugin = definePlugin('agent-status')
80
103
  definitionName: ctx.agentState.definitionName,
81
104
  timestamp: Date.now(),
82
105
  });
106
+ // Additive abnormal-terminal signal for alerting (e.g. worker crash alert).
107
+ ctx.notify('agentStopped', {
108
+ sessionId: ctx.sessionId,
109
+ agentId: ctx.agentId,
110
+ definitionName: ctx.agentState.definitionName,
111
+ kind: 'errored',
112
+ message: ctx.error,
113
+ timestamp: Date.now(),
114
+ });
83
115
  return null;
84
116
  })
85
117
  .hook('onPause', async (ctx) => {
@@ -93,6 +125,20 @@ export const agentStatusPlugin = definePlugin('agent-status')
93
125
  definitionName: ctx.agentState.definitionName,
94
126
  timestamp: Date.now(),
95
127
  });
128
+ // Additive abnormal-terminal signal carrying the structured pause reason and
129
+ // message. Read from agentState (set by the agent_paused reducer) rather than
130
+ // the loosely-typed `ctx.reason`, which actually carries the message string.
131
+ // A budget breach surfaces as reason:'handler' with the budget detail in
132
+ // `message` (limits-guard pauses via beforeInference `{action:'pause'}`).
133
+ ctx.notify('agentStopped', {
134
+ sessionId: ctx.sessionId,
135
+ agentId: ctx.agentId,
136
+ definitionName: ctx.agentState.definitionName,
137
+ kind: 'paused',
138
+ reason: ctx.agentState.pauseReason,
139
+ message: ctx.agentState.pauseMessage,
140
+ timestamp: Date.now(),
141
+ });
96
142
  return null;
97
143
  })
98
144
  .build();
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/plugins/agent-status/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,CAAC,MAAM,QAAQ,CAAA;AACtB,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC,cAAc,CAAC;KAC3D,YAAY,CAAC,aAAa,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,SAAS,EAAE,eAAe;QAC1B,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,yBAAyB;QACjC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACrC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACrB,CAAC;CACF,CAAC;KACD,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EA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QAClC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,YAAY;QACpC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACrB,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACZ,CAAC,CAAC;KACD,KAAK,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roj-ai/sdk",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
@@ -135,7 +135,7 @@
135
135
  "type-check": "tsc --noEmit"
136
136
  },
137
137
  "dependencies": {
138
- "@roj-ai/transport": "^0.1.21",
138
+ "@roj-ai/transport": "^0.1.22",
139
139
  "@hono/zod-validator": "0.7.6",
140
140
  "hono": "4.12.5",
141
141
  "ignore": "7.0.5",
package/src/index.ts CHANGED
@@ -82,7 +82,8 @@ export type { BuiltinEvent } from './builtin-events.js'
82
82
  export type { AgentChatMessage, AskUserChatMessage, ChatMessage, UserChatMessage } from '~/plugins/user-chat/index.js'
83
83
 
84
84
  // Plugins
85
- export { agentStatusPlugin } from '~/plugins/agent-status/plugin.js'
85
+ export { agentStatusPlugin, agentStoppedNotificationSchema } from '~/plugins/agent-status/plugin.js'
86
+ export type { AgentStoppedNotification } from '~/plugins/agent-status/plugin.js'
86
87
  export { agentsPlugin } from '~/plugins/agents/plugin.js'
87
88
  export type { AgentsPluginConfig } from '~/plugins/agents/plugin.js'
88
89
  export { contextCompactPlugin } from '~/plugins/context-compact/plugin.js'
@@ -0,0 +1,164 @@
1
+ import { describe, expect, it } from 'bun:test'
2
+ import { AgentId } from '~/core/agents/schema.js'
3
+ import { MockLLMProvider } from '~/core/llm/mock.js'
4
+ import type { PluginNotification } from '~/core/plugins/plugin-builder.js'
5
+ import { ToolCallId } from '~/core/tools/schema.js'
6
+ import { limitsGuardPlugin } from '~/plugins/limits-guard/plugin.js'
7
+ import { createMultiAgentPreset, createTestPreset, type TestSession, TestHarness } from '~/testing/index.js'
8
+ import { type AgentStoppedNotification, agentStatusPlugin } from './plugin.js'
9
+
10
+ type StatusPayload = { sessionId: string; agentId: string; status: string; definitionName?: string; timestamp: number }
11
+
12
+ const agentStatusNotifications = (session: TestSession): StatusPayload[] =>
13
+ session.getNotifications()
14
+ .filter((n: PluginNotification) => n.pluginName === 'agent-status' && n.type === 'agentStatus')
15
+ .map((n) => n.payload as StatusPayload)
16
+
17
+ const agentStoppedNotifications = (session: TestSession): AgentStoppedNotification[] =>
18
+ session.getNotifications()
19
+ .filter((n: PluginNotification) => n.pluginName === 'agent-status' && n.type === 'agentStopped')
20
+ .map((n) => n.payload as AgentStoppedNotification)
21
+
22
+ async function waitForAgentStatus(session: TestSession, agentId: AgentId, status: string, timeoutMs = 5000): Promise<void> {
23
+ const deadline = Date.now() + timeoutMs
24
+ while (Date.now() < deadline) {
25
+ const agentState = session.state.agents.get(agentId)
26
+ if (agentState?.status === status) return
27
+ await new Promise((r) => setTimeout(r, 10))
28
+ }
29
+ throw new Error(`waitForAgentStatus timed out after ${timeoutMs}ms (wanted ${status}) for agent ${agentId}`)
30
+ }
31
+
32
+ describe('agent-status plugin', () => {
33
+ describe('agentStatus (existing behavior)', () => {
34
+ it('emits thinking on start and idle on completion', async () => {
35
+ const harness = new TestHarness({
36
+ presets: [createTestPreset()],
37
+ systemPlugins: [agentStatusPlugin],
38
+ llmProvider: MockLLMProvider.withFixedResponse({ content: 'Done', toolCalls: [] }),
39
+ })
40
+
41
+ const session = await harness.createSession('test')
42
+ const entryAgentId = session.getEntryAgentId()!
43
+ await session.sendAndWaitForIdle('Hello')
44
+
45
+ const statuses = agentStatusNotifications(session).map((p) => p.status)
46
+ expect(statuses).toContain('thinking')
47
+ expect(statuses).toContain('idle')
48
+
49
+ // No abnormal-terminal notification for a normal completion.
50
+ expect(agentStoppedNotifications(session)).toHaveLength(0)
51
+
52
+ await harness.shutdown()
53
+ })
54
+ })
55
+
56
+ describe('agentStopped on pause', () => {
57
+ it('manual pause → agentStopped kind:paused reason:manual with message', async () => {
58
+ let orchestratorCalls = 0
59
+ const harness = new TestHarness({
60
+ presets: [createMultiAgentPreset(
61
+ [{ name: 'worker', system: 'Worker agent.', tools: [], agents: [] }],
62
+ { orchestratorSystem: 'Orchestrator agent.' },
63
+ )],
64
+ systemPlugins: [agentStatusPlugin],
65
+ mockHandler: (request) => {
66
+ if (request.systemPrompt.includes('Orchestrator')) {
67
+ orchestratorCalls++
68
+ if (orchestratorCalls === 1) {
69
+ return {
70
+ content: null,
71
+ toolCalls: [{ id: ToolCallId('tc1'), name: 'start_worker', input: { message: 'Work' } }],
72
+ finishReason: 'stop',
73
+ metrics: MockLLMProvider.defaultMetrics(),
74
+ }
75
+ }
76
+ return { content: 'Done', toolCalls: [], finishReason: 'stop', metrics: MockLLMProvider.defaultMetrics() }
77
+ }
78
+ return { content: 'Worker done', toolCalls: [], finishReason: 'stop', metrics: MockLLMProvider.defaultMetrics() }
79
+ },
80
+ })
81
+
82
+ const session = await harness.createSession('test')
83
+ await session.sendAndWaitForIdle('Start')
84
+
85
+ // Manual pause via Session.pauseAgent — the real manual-pause API that
86
+ // runs onPause hooks (agents.pause only emits the event, no hooks).
87
+ const innerSession = (session as unknown as { session: { pauseAgent: (id: AgentId, message?: string) => Promise<{ ok: boolean }> } }).session
88
+ const result = await innerSession.pauseAgent(AgentId('worker_1'), 'Pausing for review')
89
+ expect(result.ok).toBe(true)
90
+
91
+ const stopped = agentStoppedNotifications(session).filter((n) => n.agentId === 'worker_1')
92
+ expect(stopped).toHaveLength(1)
93
+ expect(stopped[0].kind).toBe('paused')
94
+ expect(stopped[0].reason).toBe('manual')
95
+ expect(stopped[0].message).toBe('Pausing for review')
96
+ expect(stopped[0].definitionName).toBe('worker')
97
+ expect(typeof stopped[0].timestamp).toBe('number')
98
+
99
+ // idle agentStatus still emitted alongside.
100
+ expect(agentStatusNotifications(session).some((p) => p.agentId === 'worker_1' && p.status === 'idle')).toBe(true)
101
+
102
+ await harness.shutdown()
103
+ })
104
+
105
+ it('limits-guard hard limit → agentStopped kind:paused with reason and message', async () => {
106
+ let inferenceCount = 0
107
+ const harness = new TestHarness({
108
+ presets: [createTestPreset({
109
+ orchestratorSystem: 'Test agent.',
110
+ orchestratorPlugins: [limitsGuardPlugin.configureAgent({ limits: { maxTurns: 2 } })],
111
+ })],
112
+ systemPlugins: [agentStatusPlugin, limitsGuardPlugin],
113
+ mockHandler: () => {
114
+ inferenceCount++
115
+ return {
116
+ content: null,
117
+ toolCalls: [{ id: ToolCallId(`tc${inferenceCount}`), name: 'tell_user', input: { message: `Turn ${inferenceCount}` } }],
118
+ finishReason: 'stop',
119
+ metrics: MockLLMProvider.defaultMetrics(),
120
+ }
121
+ },
122
+ })
123
+
124
+ const session = await harness.createSession('test')
125
+ const entryAgentId = session.getEntryAgentId()!
126
+ await session.sendMessage('Start')
127
+ await waitForAgentStatus(session, entryAgentId, 'paused')
128
+
129
+ const stopped = agentStoppedNotifications(session).filter((n) => n.agentId === String(entryAgentId))
130
+ expect(stopped.length).toBeGreaterThanOrEqual(1)
131
+ expect(stopped[0].kind).toBe('paused')
132
+ // limits-guard pauses via beforeInference {action:'pause'} → reason 'handler',
133
+ // with the human-readable budget detail in `message`.
134
+ expect(stopped[0].reason).toBe('handler')
135
+ expect(stopped[0].message).toBeTruthy()
136
+
137
+ await harness.shutdown()
138
+ })
139
+ })
140
+
141
+ describe('agentStopped on error', () => {
142
+ it('non-retryable LLM error → agentStopped kind:errored with message', async () => {
143
+ const harness = new TestHarness({
144
+ presets: [createTestPreset()],
145
+ systemPlugins: [agentStatusPlugin],
146
+ llmProvider: MockLLMProvider.withError({ type: 'invalid_request', message: 'Bad request' }),
147
+ })
148
+
149
+ const session = await harness.createSession('test')
150
+ const entryAgentId = session.getEntryAgentId()!
151
+ await session.sendMessage('Trigger error')
152
+ await waitForAgentStatus(session, entryAgentId, 'errored')
153
+
154
+ const stopped = agentStoppedNotifications(session).filter((n) => n.agentId === String(entryAgentId))
155
+ expect(stopped).toHaveLength(1)
156
+ expect(stopped[0].kind).toBe('errored')
157
+ expect(stopped[0].reason).toBeUndefined()
158
+ expect(stopped[0].message).toBe('Bad request')
159
+ expect(stopped[0].definitionName).toBeDefined()
160
+
161
+ await harness.shutdown()
162
+ })
163
+ })
164
+ })
@@ -14,6 +14,11 @@
14
14
  * `idle` fires on `onComplete`, `onError`, and `onPause` — covers every terminal
15
15
  * state of an agent turn, including hard-limit pauses (limits-guard) and manual
16
16
  * `Session.pauseAgent` calls that would otherwise leave the indicator hung.
17
+ *
18
+ * Alongside the `idle` status, abnormal terminal states (pause / error) also emit
19
+ * a dedicated `agentStopped` notification carrying the pause reason / error detail,
20
+ * so consumers (e.g. a Cloudflare worker) can alert on a budget pause or crash —
21
+ * which the coarse `idle` status alone can't distinguish from a normal completion.
17
22
  */
18
23
 
19
24
  import z from 'zod/v4'
@@ -21,6 +26,24 @@ import { agentIdSchema, protocolAgentStatusSchema } from '~/core/agents/schema.j
21
26
  import { definePlugin } from '~/core/plugins/index.js'
22
27
  import { sessionIdSchema } from '~/core/sessions/schema.js'
23
28
 
29
+ /**
30
+ * Payload for the `agentStopped` notification — emitted when an agent reaches an
31
+ * abnormal terminal state (paused or errored), as opposed to a normal idle.
32
+ */
33
+ export const agentStoppedNotificationSchema = z.object({
34
+ sessionId: sessionIdSchema,
35
+ agentId: agentIdSchema,
36
+ definitionName: z.string().optional(),
37
+ kind: z.enum(['paused', 'errored']),
38
+ /** Present when kind === 'paused' — why the agent was paused. */
39
+ reason: z.enum(['limit', 'handler', 'manual']).optional(),
40
+ /** Human-readable detail (budget message / error message). */
41
+ message: z.string().optional(),
42
+ timestamp: z.number(),
43
+ })
44
+
45
+ export type AgentStoppedNotification = z.infer<typeof agentStoppedNotificationSchema>
46
+
24
47
  export const agentStatusPlugin = definePlugin('agent-status')
25
48
  .notification('agentStatus', {
26
49
  schema: z.object({
@@ -31,6 +54,9 @@ export const agentStatusPlugin = definePlugin('agent-status')
31
54
  timestamp: z.number(),
32
55
  }),
33
56
  })
57
+ .notification('agentStopped', {
58
+ schema: agentStoppedNotificationSchema,
59
+ })
34
60
  .hook('onStart', async (ctx) => {
35
61
  ctx.notify('agentStatus', {
36
62
  sessionId: ctx.sessionId,
@@ -82,6 +108,15 @@ export const agentStatusPlugin = definePlugin('agent-status')
82
108
  definitionName: ctx.agentState.definitionName,
83
109
  timestamp: Date.now(),
84
110
  })
111
+ // Additive abnormal-terminal signal for alerting (e.g. worker crash alert).
112
+ ctx.notify('agentStopped', {
113
+ sessionId: ctx.sessionId,
114
+ agentId: ctx.agentId,
115
+ definitionName: ctx.agentState.definitionName,
116
+ kind: 'errored',
117
+ message: ctx.error,
118
+ timestamp: Date.now(),
119
+ })
85
120
  return null
86
121
  })
87
122
  .hook('onPause', async (ctx) => {
@@ -95,6 +130,20 @@ export const agentStatusPlugin = definePlugin('agent-status')
95
130
  definitionName: ctx.agentState.definitionName,
96
131
  timestamp: Date.now(),
97
132
  })
133
+ // Additive abnormal-terminal signal carrying the structured pause reason and
134
+ // message. Read from agentState (set by the agent_paused reducer) rather than
135
+ // the loosely-typed `ctx.reason`, which actually carries the message string.
136
+ // A budget breach surfaces as reason:'handler' with the budget detail in
137
+ // `message` (limits-guard pauses via beforeInference `{action:'pause'}`).
138
+ ctx.notify('agentStopped', {
139
+ sessionId: ctx.sessionId,
140
+ agentId: ctx.agentId,
141
+ definitionName: ctx.agentState.definitionName,
142
+ kind: 'paused',
143
+ reason: ctx.agentState.pauseReason,
144
+ message: ctx.agentState.pauseMessage,
145
+ timestamp: Date.now(),
146
+ })
98
147
  return null
99
148
  })
100
149
  .build()