@ziggs-ai/agent-sdk 0.46.8 → 0.47.0
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/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/dist/Agent.d.ts +5 -7
- package/dist/Agent.js +29 -60
- package/dist/brain/ClaudeBrain.d.ts +3 -3
- package/dist/brain/ClaudeBrain.js +4 -5
- package/dist/brain/claudeCognition.js +2 -2
- package/dist/brain/claudeSdkProtocol.js +5 -5
- package/dist/brain/claudeSdkTools.d.ts +0 -1
- package/dist/brain/claudeSdkTools.js +1 -1
- package/dist/brain/wakeGate.d.ts +0 -3
- package/dist/brain/wakeGate.js +0 -6
- package/dist/ingress/normalizeIncoming.d.ts +0 -2
- package/dist/ingress/normalizeIncoming.js +0 -9
- package/dist/mcp/createMcpAgent.js +2 -2
- package/dist/memory/MemoryStore.d.ts +5 -5
- package/dist/memory/MemoryStore.js +4 -4
- package/dist/platform/OutboxBuffer.d.ts +2 -2
- package/dist/platform/OutboxBuffer.js +17 -17
- package/dist/platform/WakeLedger.d.ts +0 -2
- package/dist/platform/WakeLedger.js +0 -1
- package/dist/platform/ZiggsEffectHandler.d.ts +0 -1
- package/dist/platform/ZiggsEffectHandler.js +8 -12
- package/dist/platform/inboxLoop.js +1 -2
- package/dist/platform/polls/PollKind.d.ts +2 -2
- package/dist/platform/polls/PollKind.js +1 -1
- package/dist/platform/telemetryIngest.js +1 -4
- package/dist/platform/tools/tier1/protocolRunner.d.ts +3 -1
- package/dist/platform/tools/tier1/protocolRunner.js +10 -23
- package/dist/platform/tools/tier1/protocolTools.js +2 -2
- package/dist/platform/tools/tier1/wakeTools.d.ts +0 -1
- package/dist/platform/tools/tier2/listingTools.js +1 -1
- package/dist/platform/tools/tier2/mcpConnectionTools.js +1 -1
- package/dist/platform/tools/tier2/partyTools.js +2 -2
- package/dist/platform/tools/tier2/planTools.d.ts +2 -2
- package/dist/platform/tools/tier2/planTools.js +3 -3
- package/dist/runtime/AgentMachine.d.ts +1 -1
- package/dist/runtime/AgentMachine.js +1 -1
- package/dist/runtime/PromptBuilder.d.ts +1 -1
- package/dist/runtime/PromptBuilder.js +7 -9
- package/dist/runtime/agreementContext.d.ts +4 -4
- package/dist/runtime/agreementContext.js +4 -4
- package/dist/runtime/buildOutcome.d.ts +0 -1
- package/dist/runtime/deliveryWriteKeys.d.ts +1 -2
- package/dist/runtime/deliveryWriteKeys.js +1 -2
- package/dist/runtime/kickoff.d.ts +2 -2
- package/dist/runtime/kickoff.js +2 -2
- package/dist/runtime/messageCommand.d.ts +1 -1
- package/dist/runtime/messageCommand.js +1 -1
- package/dist/runtime/runTurn.js +5 -18
- package/dist/runtime/wakeEffects.d.ts +1 -1
- package/dist/runtime/wakeEffects.js +1 -1
- package/dist/runtime/wakeOutcome.js +0 -1
- package/dist/tools/recordReport.d.ts +3 -5
- package/dist/tools/recordReport.js +4 -11
- package/dist/tools/toolCreds.d.ts +4 -4
- package/dist/tools/toolCreds.js +5 -7
- package/dist/types.d.ts +7 -9
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
/** Compose an FSM message from the current wake. A session locates the wake
|
|
3
|
-
* context; it is never a
|
|
3
|
+
* context; it is never a destination, principal or authority identifier.
|
|
4
4
|
*
|
|
5
5
|
* A reply from a wake names nobody: the backend links it to the trigger and
|
|
6
6
|
* fills readers and recipients from the trigger's own readers and sender. An
|
package/dist/runtime/runTurn.js
CHANGED
|
@@ -118,7 +118,7 @@ export async function runTurn(input) {
|
|
|
118
118
|
statePrompt, actions,
|
|
119
119
|
serverContext: { context: ctxObj, tools: tools },
|
|
120
120
|
incomingEvent, definition,
|
|
121
|
-
|
|
121
|
+
sessionId, stateId, ctx,
|
|
122
122
|
omitMessageFromRespond: streamRespondActions,
|
|
123
123
|
});
|
|
124
124
|
const systemContent = tools.length > 0
|
|
@@ -375,7 +375,7 @@ export async function runTurn(input) {
|
|
|
375
375
|
receiverId: decision.receiverId,
|
|
376
376
|
}) ?? chunkMessageId;
|
|
377
377
|
await eff({ kind: 'send-message', sessionId, command: await responseCommand(eff, sessionId, safeText, { recipientId: decision.receiverId, operationId: persistMessageId }) });
|
|
378
|
-
allEmittedEvents.push({ type: 'message_sent', receiverId: decision.receiverId,
|
|
378
|
+
allEmittedEvents.push({ type: 'message_sent', receiverId: decision.receiverId, message: safeText, senderId: 'system' });
|
|
379
379
|
lastAction = chosenAction;
|
|
380
380
|
lastActionDef = actionDef;
|
|
381
381
|
}
|
|
@@ -682,19 +682,13 @@ function truncateMsg(msg) {
|
|
|
682
682
|
return msg.slice(0, MAX_MSG_CHARS) + `\n\n[truncated to ${MAX_MSG_CHARS} of ${msg.length} chars]`;
|
|
683
683
|
}
|
|
684
684
|
async function executeSendMessage(decision, eff, sessionId) {
|
|
685
|
-
if (decision.addressId && decision.addressId !== sessionId)
|
|
686
|
-
throw new Error('A response cannot route through a room. Use message_send with explicit recipients and mandate.');
|
|
687
|
-
const targetSessionId = sessionId;
|
|
688
685
|
const safeMessage = truncateMsg(decision.message);
|
|
689
686
|
const receiverId = decision.receiverId || undefined;
|
|
690
687
|
await eff({
|
|
691
688
|
kind: 'send-message', sessionId,
|
|
692
689
|
command: await responseCommand(eff, sessionId, safeMessage, { recipientId: receiverId }),
|
|
693
690
|
});
|
|
694
|
-
|
|
695
|
-
if (targetSessionId !== sessionId)
|
|
696
|
-
events.push({ type: 'report_sent', message: 'Reported to owner.', senderId: 'system' });
|
|
697
|
-
return events;
|
|
691
|
+
return [{ type: 'message_sent', ...(receiverId ? { receiverId } : {}), message: safeMessage, senderId: 'system' }];
|
|
698
692
|
}
|
|
699
693
|
/**
|
|
700
694
|
* Multi-message send. `message_sent` is emitted ONLY for sends that actually
|
|
@@ -714,11 +708,6 @@ async function executeSendMessages(decision, eff, sessionId) {
|
|
|
714
708
|
failures.push({ receiverId: msg.receiverId || '<missing>', error: 'missing message' });
|
|
715
709
|
continue;
|
|
716
710
|
}
|
|
717
|
-
if (msg.addressId && msg.addressId !== sessionId) {
|
|
718
|
-
failures.push({ receiverId: msg.receiverId, error: 'Use message_send with explicit recipients and mandate for a separate destination' });
|
|
719
|
-
continue;
|
|
720
|
-
}
|
|
721
|
-
const targetSessionId = sessionId;
|
|
722
711
|
const safeMessage = truncateMsg(msg.message);
|
|
723
712
|
attempted++;
|
|
724
713
|
try {
|
|
@@ -733,9 +722,7 @@ async function executeSendMessages(decision, eff, sessionId) {
|
|
|
733
722
|
failures.push({ receiverId: msg.receiverId, error: err.message });
|
|
734
723
|
continue;
|
|
735
724
|
}
|
|
736
|
-
events.push({ type: 'message_sent', receiverId: msg.receiverId,
|
|
737
|
-
if (targetSessionId !== sessionId)
|
|
738
|
-
events.push({ type: 'report_sent', message: 'Reported to owner.', senderId: 'system' });
|
|
725
|
+
events.push({ type: 'message_sent', receiverId: msg.receiverId, message: safeMessage, senderId: 'system' });
|
|
739
726
|
}
|
|
740
727
|
if (attempted === 0)
|
|
741
728
|
return null; // every entry malformed — LLM output defect, caller reprompts
|
|
@@ -824,7 +811,7 @@ async function echoOptInToolSummaryIfNeeded({ allEmittedEvents, eff, sessionId,
|
|
|
824
811
|
catch {
|
|
825
812
|
return;
|
|
826
813
|
}
|
|
827
|
-
const event = { type: 'message_sent', receiverId,
|
|
814
|
+
const event = { type: 'message_sent', receiverId, message: safe, senderId: 'system' };
|
|
828
815
|
if (wasTruncated) {
|
|
829
816
|
event['truncated'] = true;
|
|
830
817
|
event['originalLength'] = summary.length;
|
|
@@ -12,7 +12,7 @@ export declare function contextScopesFromWake(event: unknown, sessionId: string)
|
|
|
12
12
|
messageId?: string;
|
|
13
13
|
artifactId?: string;
|
|
14
14
|
}>;
|
|
15
|
-
/** Per-wake observation, including effects nested inside tools and
|
|
15
|
+
/** Per-wake observation, including effects nested inside tools and sends to other conversations. */
|
|
16
16
|
export declare class WakeEffects {
|
|
17
17
|
private readonly initialScope;
|
|
18
18
|
private readonly inferScope;
|
|
@@ -42,7 +42,7 @@ export function contextScopesFromWake(event, sessionId) {
|
|
|
42
42
|
? [{ ...scope, ...(messageId ? { messageId } : {}), ...(artifactId ? { artifactId } : {}) }] : [];
|
|
43
43
|
}
|
|
44
44
|
const TASK_WRITES = new Set(['task_create', 'task_set_result', 'task_update_plan_step', 'task_replace_plan']);
|
|
45
|
-
/** Per-wake observation, including effects nested inside tools and
|
|
45
|
+
/** Per-wake observation, including effects nested inside tools and sends to other conversations. */
|
|
46
46
|
export class WakeEffects {
|
|
47
47
|
initialScope;
|
|
48
48
|
inferScope;
|
|
@@ -13,12 +13,10 @@ export interface RecordReportInput {
|
|
|
13
13
|
taskId: string;
|
|
14
14
|
report: TaskReport;
|
|
15
15
|
/**
|
|
16
|
-
* Optional
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* shows up. Pass at most one; when both arrive, agreementId wins.
|
|
16
|
+
* Optional agreement for the deliverable artifact. The task binding is what
|
|
17
|
+
* makes the deliverable retrievable and readable by the task's parties; an
|
|
18
|
+
* agreement only widens where it also shows up.
|
|
20
19
|
*/
|
|
21
|
-
addressId?: string;
|
|
22
20
|
agreementId?: string;
|
|
23
21
|
/**
|
|
24
22
|
* Heavy deliverable text (document, diff, data).
|
|
@@ -14,18 +14,11 @@ import { ArtifactsClient, updateTaskState, } from '@ziggs-ai/api-client';
|
|
|
14
14
|
* Implements the B1 convention (Agents/REPORTING.md).
|
|
15
15
|
*/
|
|
16
16
|
export async function recordReport(input) {
|
|
17
|
-
const { creds, taskId, report,
|
|
18
|
-
//
|
|
17
|
+
const { creds, taskId, report, agreementId, deliverable } = input;
|
|
18
|
+
// No container needed. The deliverable is bound to its task, which
|
|
19
19
|
// is what makes it retrievable as `via=task:<taskId>` and readable by the
|
|
20
|
-
// task's parties
|
|
21
|
-
|
|
22
|
-
// the agreement still wins here, and this is now the ONE place that
|
|
23
|
-
// resolves rather than refuses — deliberately, because the caller is not a
|
|
24
|
-
// model choosing arguments. `recordReport` is handed both ids by the runtime
|
|
25
|
-
// (the task's agreement and the chat it is running in), so there is no
|
|
26
|
-
// mistake to surface and nobody to retry: refusing would fail a finished
|
|
27
|
-
// task's delivery over a pair of ids it did not choose.
|
|
28
|
-
const scope = agreementId ? { agreementId } : addressId ? { addressId } : {};
|
|
20
|
+
// task's parties.
|
|
21
|
+
const scope = agreementId ? { agreementId } : {};
|
|
29
22
|
// Deliverable FIRST, then close the task.
|
|
30
23
|
//
|
|
31
24
|
// The old order completed the task and then wrote the artifact with the
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* A custom tool builds `{ operatorKey, agentId }` by hand and stops there, so
|
|
5
5
|
* every call it makes runs on the narrowest reach fence there is: the agent's
|
|
6
6
|
* own org. `Agent` already threads the wake's lane into the tool context
|
|
7
|
-
* (as `
|
|
7
|
+
* (as `sessionId`, which is what the capability adapter reads), and
|
|
8
8
|
* the backend's fence is "own org ∪ the orgs of the parties to this lane" — so
|
|
9
9
|
* a tool that does not pass it loses reach it is entitled to, and loses it
|
|
10
10
|
* SILENTLY: enumerations come back short rather than refused.
|
|
@@ -23,14 +23,14 @@ import { type Creds } from '@ziggs-ai/api-client';
|
|
|
23
23
|
/** The loose bag `defineTool` hands a handler. */
|
|
24
24
|
type ToolContext = Record<string, unknown> | undefined | null;
|
|
25
25
|
/**
|
|
26
|
-
* The wake's lane, as the backend's `X-Ziggs-Lane` expects it:
|
|
26
|
+
* The wake's lane, as the backend's `X-Ziggs-Lane` expects it: for example
|
|
27
27
|
* `agrn-<agreementId>` for an agreement lane. Undefined when the tool is
|
|
28
28
|
* running outside any lane (a bootstrap sweep, a test), which the fence reads
|
|
29
29
|
* as "own org only".
|
|
30
30
|
*
|
|
31
|
-
* A
|
|
31
|
+
* A wake that handles mail under an agreement (`wakeAgreementId`, taken
|
|
32
32
|
* from the delivery itself) names it too, so the backend scopes the wake to
|
|
33
|
-
* that agreement rather than inferring it from the
|
|
33
|
+
* that agreement rather than inferring it from the mail.
|
|
34
34
|
*/
|
|
35
35
|
export declare function laneFromToolContext(ctx: ToolContext): string | undefined;
|
|
36
36
|
/**
|
package/dist/tools/toolCreds.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* A custom tool builds `{ operatorKey, agentId }` by hand and stops there, so
|
|
5
5
|
* every call it makes runs on the narrowest reach fence there is: the agent's
|
|
6
6
|
* own org. `Agent` already threads the wake's lane into the tool context
|
|
7
|
-
* (as `
|
|
7
|
+
* (as `sessionId`, which is what the capability adapter reads), and
|
|
8
8
|
* the backend's fence is "own org ∪ the orgs of the parties to this lane" — so
|
|
9
9
|
* a tool that does not pass it loses reach it is entitled to, and loses it
|
|
10
10
|
* SILENTLY: enumerations come back short rather than refused.
|
|
@@ -25,19 +25,17 @@ const str = (ctx, key) => {
|
|
|
25
25
|
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
|
-
* The wake's lane, as the backend's `X-Ziggs-Lane` expects it:
|
|
28
|
+
* The wake's lane, as the backend's `X-Ziggs-Lane` expects it: for example
|
|
29
29
|
* `agrn-<agreementId>` for an agreement lane. Undefined when the tool is
|
|
30
30
|
* running outside any lane (a bootstrap sweep, a test), which the fence reads
|
|
31
31
|
* as "own org only".
|
|
32
32
|
*
|
|
33
|
-
* A
|
|
33
|
+
* A wake that handles mail under an agreement (`wakeAgreementId`, taken
|
|
34
34
|
* from the delivery itself) names it too, so the backend scopes the wake to
|
|
35
|
-
* that agreement rather than inferring it from the
|
|
35
|
+
* that agreement rather than inferring it from the mail.
|
|
36
36
|
*/
|
|
37
37
|
export function laneFromToolContext(ctx) {
|
|
38
|
-
|
|
39
|
-
// explicit conversation, so it is the lane only where nothing else is.
|
|
40
|
-
const lane = str(ctx, 'sessionId') ?? str(ctx, 'addressId');
|
|
38
|
+
const lane = str(ctx, 'sessionId');
|
|
41
39
|
return lane ? laneUnderAgreement(lane, str(ctx, 'wakeAgreementId')) : undefined;
|
|
42
40
|
}
|
|
43
41
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -137,9 +137,9 @@ export type Outcome = {
|
|
|
137
137
|
* `{ sessionId, ctx, queue, parked }`. `Identity` is the Agent's view of
|
|
138
138
|
* which session this tick belongs to. `sessionId` is opaque to the Agent —
|
|
139
139
|
* it's a string the Server uses to route inbound events and outbound
|
|
140
|
-
* effects. (Today, the Ziggs transport derives sessionId from
|
|
141
|
-
* the wire boundary;
|
|
142
|
-
* shapes.)
|
|
140
|
+
* effects. (Today, the Ziggs transport derives sessionId from the wake's
|
|
141
|
+
* agreement, bucket or message at the wire boundary; other surfaces will
|
|
142
|
+
* produce sessionIds of other shapes.)
|
|
143
143
|
*/
|
|
144
144
|
export interface Identity {
|
|
145
145
|
agentId: string;
|
|
@@ -443,7 +443,7 @@ export interface DeliveryWriteKeys {
|
|
|
443
443
|
taskStateKey(taskId: string, state: string): string | undefined;
|
|
444
444
|
/**
|
|
445
445
|
* Default messageId for a chat-message send of this wake — the backend dedups
|
|
446
|
-
* on
|
|
446
|
+
* on messageId. Derived from the emission's content (text + chat +
|
|
447
447
|
* receiver), not a per-wake ordinal: a wake that says two things
|
|
448
448
|
* gets two keys, and a redelivered wake that re-says the same text reuses the
|
|
449
449
|
* same key, while a re-think with different text does not collide and drop.
|
|
@@ -524,10 +524,8 @@ export type Effect = {
|
|
|
524
524
|
checkout?: import('./checkout/tools.js').CheckoutSession;
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
527
|
-
* `receiverId` is optional:
|
|
528
|
-
*
|
|
529
|
-
* available when the wake's sender belongs to a DIFFERENT room.
|
|
530
|
-
* Name a receiver whenever the room holds more than two parties.
|
|
527
|
+
* `receiverId` is optional: without one, a reply goes to the sender of the
|
|
528
|
+
* message it answers. Name a receiver whenever you mean someone else.
|
|
531
529
|
*/
|
|
532
530
|
| {
|
|
533
531
|
kind: 'send-message';
|
|
@@ -556,7 +554,7 @@ export interface EffectResultMap {
|
|
|
556
554
|
/**
|
|
557
555
|
* `{ ok: true }` said the call did not throw, and a brain reading it had no
|
|
558
556
|
* way to tell a message that woke the agent it meant to from one the server
|
|
559
|
-
* widened to
|
|
557
|
+
* widened to other people. The send's own report rides along when the
|
|
560
558
|
* backend makes one: where it went. Routing is separate from acceptance.
|
|
561
559
|
*/
|
|
562
560
|
'send-message': MessageCommandResult & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Agent framework SDK for building autonomous agents on the Ziggs platform",
|
|
5
5
|
"homepage": "https://ziggsai.com/docs",
|
|
6
6
|
"bugs": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@anthropic-ai/claude-agent-sdk": "^0.3.284",
|
|
31
31
|
"@anthropic-ai/sdk": "^0.110.0",
|
|
32
32
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
33
|
-
"@ziggs-ai/api-client": "0.
|
|
33
|
+
"@ziggs-ai/api-client": "0.41.0",
|
|
34
34
|
"@ziggs-ai/contracts": "0.48.1",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
36
|
"dotenv": "^17.2.3",
|