@ziggs-ai/agent-sdk 0.5.0 → 0.7.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/dist/AgentHost.d.ts +22 -1
- package/dist/AgentHost.js +61 -13
- package/dist/agent/Agent.d.ts +9 -0
- package/dist/agent/ClaudeSdkAgent.d.ts +1 -1
- package/dist/agent/ClaudeSdkAgent.js +48 -13
- package/dist/agent/claudeCognition.js +1 -1
- package/dist/agent/claudeSdkProtocol.d.ts +1 -1
- package/dist/agent/claudeSdkProtocol.js +3 -3
- package/dist/agent/claudeSdkTools.d.ts +2 -2
- package/dist/agent/claudeSdkTools.js +12 -12
- package/dist/context/routingLabels.js +1 -1
- package/dist/defineAgent.d.ts +10 -5
- package/dist/defineAgent.js +16 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/runtime/deriveRespondsToProposals.d.ts +1 -1
- package/dist/runtime/deriveRespondsToProposals.js +1 -1
- package/dist/runtime/kickoff.js +3 -3
- package/dist/runtime/runTurn.js +54 -9
- package/dist/runtime/taskIntake.d.ts +18 -0
- package/dist/runtime/taskIntake.js +113 -0
- package/dist/server/ConnectionPool.d.ts +9 -2
- package/dist/server/ConnectionPool.js +18 -2
- package/dist/server/ZiggsEffectHandler.d.ts +1 -1
- package/dist/server/ZiggsEffectHandler.js +2 -2
- package/dist/server/agreements/AgreementService.d.ts +13 -0
- package/dist/server/agreements/AgreementService.js +16 -1
- package/dist/server/inboxLoop.d.ts +31 -11
- package/dist/server/inboxLoop.js +147 -104
- package/dist/server/runLauncher.js +9 -3
- package/dist/server/staleBacklogGate.d.ts +9 -5
- package/dist/server/staleBacklogGate.js +17 -37
- package/dist/server/tools/index.d.ts +2 -2
- package/dist/server/tools/index.js +6 -4
- package/dist/server/tools/tier1/protocolRunner.d.ts +1 -1
- package/dist/server/tools/tier1/protocolRunner.js +30 -2
- package/dist/server/tools/tier1/protocolTools.d.ts +5 -4
- package/dist/server/tools/tier1/protocolTools.js +10 -9
- package/dist/server/tools/tier2/chatTools.js +1 -1
- package/dist/server/tools/tier2/connectionTools.js +2 -2
- package/dist/server/tools/tier2/linkTools.d.ts +2 -5
- package/dist/server/tools/tier2/linkTools.js +7 -6
- package/dist/server/tools/tier2/marketplaceTools.d.ts +1 -1
- package/dist/server/tools/tier2/marketplaceTools.js +9 -22
- package/dist/tasks/protocolRegistry.d.ts +5 -4
- package/dist/tasks/protocolRegistry.js +5 -4
- package/dist/tools/recordReport.d.ts +1 -1
- package/dist/types.d.ts +4 -3
- package/package.json +2 -2
|
@@ -19,19 +19,20 @@ function handlerFor(operation) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
export const agreementProposeTool = defineTool('agreement_propose', { description: { type: 'string', required: true }, proposedTo: { type: 'string', required: true }, engagementKind: { type: 'string', enum: ['hire', 'service'], description:
|
|
22
|
+
export const agreementProposeTool = defineTool('agreement_propose', { description: { type: 'string', required: true }, proposedTo: { type: 'string', required: true }, engagementKind: { type: 'string', enum: ['hire', 'service', 'link'], description: "Contract type. Defaults to service. 'link' proposes a bilateral trust link (no work, no money)." }, parentAgreementId: 'string', parentTaskId: 'string', providerId: { type: 'string', description: 'Who does the work — required on direct proposals. Pass your own id when YOU are offering to do the work, or the proposedTo id when you are commissioning the RECIPIENT (any other third party needs a matching published offer). On a broadcast: omit for a quest (the claimer works, you pay), or pass your own id to publish a standing offer (you work, the claimer pays). The payer is always derived as the non-providing side.' }, price: 'number', lifecycle: 'string', expiresAt: 'string', maxExecutions: 'number', billing: { type: 'string', enum: ['total', 'per_task'], description: "How price reads: 'total' (default, escrowed and paid at the end) or 'per_task' (a rate settled as each task completes — standing agreements only, and the default for a hire)." }, agreementDescription: 'string', plan: { type: 'object' }, planReviewTiming: 'string', requireMidWorkPlanAck: 'boolean' }, handlerFor('agreement-propose'), { description: 'Propose an agreement — direct, broadcast, or link; there are no separate publish tools. Direction is stated, never guessed: providerId = your own id ("I work, you pay") or providerId = proposedTo ("you work, I pay") on direct proposals. Broadcast with proposedTo="everyone" (fully public) or "org" (your org only): no providerId publishes a QUEST any agent may claim; providerId = your own id publishes a STANDING OFFER (claiming is agreement_claim; browsing is marketplace_view). engagementKind "link" with proposedTo = an agent id proposes bilateral trust. engagementKind defaults to service. Agreements are STANDING by default (no expiry, unlimited tasks under one agreement); set expiresAt or maxExecutions only when the engagement should end on its own.', isAgreementCreation: true });
|
|
23
23
|
export const agreementSubcontractTool = defineTool('agreement_subcontract', { description: { type: 'string', required: true }, executorId: { type: 'string', required: true }, parentAgreementId: { type: 'string', required: true }, parentTaskId: 'string', payerId: 'string', price: 'number', lifecycle: 'string', expiresAt: 'string', maxExecutions: 'number', agreementDescription: 'string', plan: { type: 'object' }, planReviewTiming: 'string', requireMidWorkPlanAck: 'boolean' }, handlerFor('agreement-subcontract'), { description: 'Delegate work to another agent under an existing parent agreement. Requires parentAgreementId.', isAgreementCreation: true });
|
|
24
|
-
export const agreementRespondTool = defineTool('agreement_respond', { agreementId: { type: 'string', required: true }, action: { type: 'string', required: true, enum: ['approve', 'reject'] } }, handlerFor('agreement-respond'), { description: 'Approve or reject a pending agreement proposal.' });
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
24
|
+
export const agreementRespondTool = defineTool('agreement_respond', { agreementId: { type: 'string', required: true }, action: { type: 'string', required: true, enum: ['approve', 'reject'] } }, handlerFor('agreement-respond'), { description: 'Approve or reject a pending DIRECT agreement proposal addressed to you. Open broadcasts (quests, standing offers, link invites) have no personal approval slot — claim those with agreement_claim instead, or ignore them to pass.' });
|
|
25
|
+
export const agreementClaimTool = defineTool('agreement_claim', { agreementId: { type: 'string', required: true, description: 'The open agreement to claim (quest / offer / link invite id)' } }, handlerFor('agreement-claim'), { description: 'Claim an open broadcast agreement by id — a quest (you do the work, the publisher pays), a standing offer (you buy, the publisher works), or a link invite (bilateral trust forms immediately). You become the open party and the agreement activates. Find quests/offers with marketplace_view; direct proposals are approved with agreement_respond instead, not claimed.' });
|
|
26
|
+
export const taskSetResultTool = defineTool('task_set_result', { taskId: { type: 'string', required: true }, status: { type: 'string', required: true, enum: ['completed', 'failed', 'cancelled'] }, result: 'string' }, handlerFor('task-update'), { description: 'Transition a task to its terminal state — completed, failed, or cancelled — and record the result. Finished work is the task result: set it here, never as a chat message. Include a result string for completed tasks.' });
|
|
27
|
+
export const agreementCounterTool = defineTool('agreement_counter', { agreementId: { type: 'string', required: true }, price: 'number', agreementDescription: 'string', expiresAt: 'string', lifecycle: 'string', maxExecutions: 'number', description: 'string', plan: { type: 'object' }, planReviewTiming: 'string', requireMidWorkPlanAck: 'boolean' }, handlerFor('agreement-counter-proposal'), { description: 'Counter a pending proposal with revised terms instead of approving or rejecting. Check status first with agreement_get.' });
|
|
28
|
+
export const agreementGetTool = defineTool('agreement_get', { agreementId: { type: 'string', required: true } }, handlerFor('agreement-check-proposal'), { description: 'Read the current proposal status for an agreement (pending, approved, rejected, countered, expired).' });
|
|
28
29
|
export const agreementRevokeTool = defineTool('agreement_revoke', { agreementId: { type: 'string', required: true } }, handlerFor('agreement-revoke'), { description: 'Revoke a pending proposal you created so it can no longer be approved. Use when the user has clearly moved on to a different request before responding to the previous proposal card.' });
|
|
29
|
-
export const agreementFulfillTool = defineTool('agreement_fulfill', { agreementId: { type: 'string', required: true } }, handlerFor('agreement-fulfill'), { description: '
|
|
30
|
+
export const agreementFulfillTool = defineTool('agreement_fulfill', { agreementId: { type: 'string', required: true } }, handlerFor('agreement-fulfill'), { description: 'END an agreement you provide — permanently. Fulfilling terminates the whole relationship, not one deliverable: every grant it conferred is revoked, its shared space is torn down, and it cannot be reopened. Finished WORK is reported via task_set_result (the task closes; the agreement stays standing for the next task). Only fulfill when the engagement\'s full scope is delivered and nothing more is expected — never a standing hire that just finished a task.' });
|
|
30
31
|
export const taskUpdatePlanStepTool = defineTool('task_update_plan_step', { taskId: { type: 'string', required: true }, stepId: { type: 'string', required: true }, status: { type: 'string', required: true }, result: 'string' }, handlerFor('task-update-plan-step'), { description: "Update the status of a single step within a task's plan." });
|
|
31
|
-
export const
|
|
32
|
+
export const taskCreateTool = defineTool('task_create', { agreementId: { type: 'string', required: true }, description: { type: 'string', required: true }, parentTaskId: 'string', assigneeId: { type: 'string', description: 'Explicitly hand this task to one specific agent (e.g. a worker your orchestrator selected via agent search) instead of leaving it unassigned. Must be a party on the agreement (payer, provider, creator, or creator agent).' }, inputArtifactIds: { type: 'array', items: { type: 'string' }, description: 'ZIG-734: prior-step output artifact handles for structured input links.' }, plan: { type: 'object' }, planReviewTiming: 'string', requireMidWorkPlanAck: 'boolean' }, handlerFor('task-spawn'), { description: 'Create a new task under an existing approved agreement. Use when the contract is already in place. Pass assigneeId to delegate the task to a specific agent rather than leaving it open.' });
|
|
32
33
|
export const PROTOCOL_TOOLS = [
|
|
33
34
|
agreementProposeTool, agreementSubcontractTool,
|
|
34
|
-
agreementRespondTool,
|
|
35
|
+
agreementRespondTool, agreementClaimTool, agreementCounterTool, agreementGetTool, agreementRevokeTool,
|
|
35
36
|
agreementFulfillTool,
|
|
36
|
-
|
|
37
|
+
taskCreateTool, taskSetResultTool, taskUpdatePlanStepTool,
|
|
37
38
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CHAT_CAPABILITIES, openConversationCapability } from '@ziggs-ai/api-client';
|
|
2
2
|
import { toolFromCapability, toolsFromCapabilities } from '../../../tools/capabilityAdapter.js';
|
|
3
|
-
// ZIG-900 / ZIG-956 —
|
|
3
|
+
// ZIG-900 / ZIG-956 — chat_open only (chat listing stays a
|
|
4
4
|
// context-rail read, ZIG-626 rule); defined once in api-client's shared
|
|
5
5
|
// capability layer.
|
|
6
6
|
export const openConversationTool = toolFromCapability(openConversationCapability);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { connectionProxyCapability, requestConnectionCapability, ConnectionsClient, } from '@ziggs-ai/api-client';
|
|
2
2
|
import { defineTool } from '../../../tools/defineTool.js';
|
|
3
3
|
import { toolFromCapability } from '../../../tools/capabilityAdapter.js';
|
|
4
|
-
// ZIG-956 — connection_proxy /
|
|
4
|
+
// ZIG-956 — connection_proxy / connection_request are shared capability
|
|
5
5
|
// definitions (api-client). connection_list_grants stays SDK-only: the MCP
|
|
6
|
-
// surface folds connection listing into
|
|
6
|
+
// surface folds connection listing into ziggs_connection_list (ZIG-893
|
|
7
7
|
// allowance in the parity table).
|
|
8
8
|
export const connectionProxyTool = toolFromCapability(connectionProxyCapability);
|
|
9
9
|
export const requestConnectionTool = toolFromCapability(requestConnectionCapability);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ToolDefinition } from '../../../tools/defineTool.js';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const claimLinkInviteTool: ToolDefinition;
|
|
5
|
-
export declare const listLinksTool: ToolDefinition;
|
|
6
|
-
export declare const revokeLinkTool: ToolDefinition;
|
|
2
|
+
export declare const linkCreateInviteTool: ToolDefinition;
|
|
3
|
+
export declare const linkListTool: ToolDefinition;
|
|
7
4
|
export declare const LINK_TOOLS: ToolDefinition[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { LINK_CAPABILITIES,
|
|
1
|
+
import { LINK_CAPABILITIES, createLinkInviteCapability, listLinksCapability, } from '@ziggs-ai/api-client';
|
|
2
2
|
import { toolFromCapability, toolsFromCapabilities } from '../../../tools/capabilityAdapter.js';
|
|
3
3
|
// ZIG-898 / ZIG-956 — links are agreements with engagementKind 'link':
|
|
4
4
|
// bilateral agent-to-agent trust that gives unpublished delegates cross-org
|
|
5
5
|
// reach. Defined once in api-client's shared capability layer (including the
|
|
6
6
|
// ZIG-670 linkSummary shaping); this file only adapts them onto the SDK.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const
|
|
7
|
+
//
|
|
8
|
+
// ZIG-1021/1022 shrank the rail to two tools. The agreement verbs carry the
|
|
9
|
+
// rest: request a direct link with agreement_propose (engagementKind 'link'),
|
|
10
|
+
// claim an invite with agreement_claim, end a link with agreement_revoke.
|
|
11
|
+
export const linkCreateInviteTool = toolFromCapability(createLinkInviteCapability);
|
|
12
|
+
export const linkListTool = toolFromCapability(listLinksCapability);
|
|
12
13
|
export const LINK_TOOLS = toolsFromCapabilities(LINK_CAPABILITIES);
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!operatorKey)
|
|
11
|
-
throw new Error('operatorKey missing from tool context');
|
|
12
|
-
if (!agentId)
|
|
13
|
-
throw new Error('agentId missing from tool context');
|
|
14
|
-
const options = {
|
|
15
|
-
limit: typeof args['limit'] === 'number' ? args['limit'] : 20,
|
|
16
|
-
};
|
|
17
|
-
if (args['since'])
|
|
18
|
-
options.since = args['since'];
|
|
19
|
-
const quests = await pullQuests(options, { operatorKey, agentId });
|
|
20
|
-
return { quests, count: quests.length };
|
|
21
|
-
}, { description: 'Browse open quests on the marketplace — work buyers have broadcast to willing agents. Returns public quests plus any org-scoped quests in your org. To claim a quest, use agreement_respond on the returned agreementId. To publish your own, use agreement_propose({ proposedTo: "everyone" }) for a public quest or proposedTo: "org" to keep it inside your org.' });
|
|
22
|
-
export const MARKETPLACE_TOOLS = [marketplaceViewTool];
|
|
1
|
+
import { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from '@ziggs-ai/api-client';
|
|
2
|
+
import { toolFromCapability, toolsFromCapabilities } from '../../../tools/capabilityAdapter.js';
|
|
3
|
+
// ZIG-1023 / ZIG-956 — the marketplace read (quests AND standing offers),
|
|
4
|
+
// defined once in api-client's shared capability layer. Publishing is NOT
|
|
5
|
+
// here: it is the tier-1 verb agreement_propose with proposedTo
|
|
6
|
+
// "everyone" | "org" (providerId = own id for an offer, omitted for a quest);
|
|
7
|
+
// claiming is agreement_claim.
|
|
8
|
+
export const marketplaceViewTool = toolFromCapability(marketplaceViewCapability);
|
|
9
|
+
export const MARKETPLACE_TOOLS = toolsFromCapabilities(MARKETPLACE_CAPABILITIES);
|
|
@@ -2,11 +2,12 @@ export declare const PROTOCOL_TOOL_TO_OPERATION: Readonly<{
|
|
|
2
2
|
readonly agreement_propose: "agreement-propose";
|
|
3
3
|
readonly agreement_subcontract: "agreement-subcontract";
|
|
4
4
|
readonly agreement_respond: "agreement-respond";
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
5
|
+
readonly agreement_claim: "agreement-claim";
|
|
6
|
+
readonly agreement_counter: "agreement-counter-proposal";
|
|
7
|
+
readonly agreement_get: "agreement-check-proposal";
|
|
7
8
|
readonly agreement_revoke: "agreement-revoke";
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
9
|
+
readonly task_create: "task-spawn";
|
|
10
|
+
readonly task_set_result: "task-update";
|
|
10
11
|
readonly task_update_plan_step: "task-update-plan-step";
|
|
11
12
|
}>;
|
|
12
13
|
export type ProtocolToolName = keyof typeof PROTOCOL_TOOL_TO_OPERATION;
|
|
@@ -2,11 +2,12 @@ export const PROTOCOL_TOOL_TO_OPERATION = Object.freeze({
|
|
|
2
2
|
agreement_propose: 'agreement-propose',
|
|
3
3
|
agreement_subcontract: 'agreement-subcontract',
|
|
4
4
|
agreement_respond: 'agreement-respond',
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
agreement_claim: 'agreement-claim',
|
|
6
|
+
agreement_counter: 'agreement-counter-proposal',
|
|
7
|
+
agreement_get: 'agreement-check-proposal',
|
|
7
8
|
agreement_revoke: 'agreement-revoke',
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
task_create: 'task-spawn',
|
|
10
|
+
task_set_result: 'task-update',
|
|
10
11
|
task_update_plan_step: 'task-update-plan-step',
|
|
11
12
|
});
|
|
12
13
|
export const PROTOCOL_TOOL_NAMES = Object.freeze(Object.keys(PROTOCOL_TOOL_TO_OPERATION));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Creds } from '@ziggs-ai/api-client';
|
|
2
2
|
/**
|
|
3
3
|
* The canonical report shape (B1 convention — ZIG-561).
|
|
4
|
-
* Matches Task.result as set by
|
|
4
|
+
* Matches Task.result as set by ziggs_task_set_result.
|
|
5
5
|
*/
|
|
6
6
|
export interface TaskReport {
|
|
7
7
|
summary: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface TaskRef {
|
|
|
29
29
|
parentTaskId?: string;
|
|
30
30
|
executorId?: string;
|
|
31
31
|
assigneeId?: string | null;
|
|
32
|
-
/** Work product set by
|
|
32
|
+
/** Work product set by task_set_result (safeJsonStringify'd string on the wire). */
|
|
33
33
|
result?: unknown;
|
|
34
34
|
proposal?: {
|
|
35
35
|
status?: 'pending' | 'approved' | 'rejected' | 'cancelled';
|
|
@@ -313,8 +313,9 @@ export interface ContextSnapshot {
|
|
|
313
313
|
* The session's chat no longer resolves on the backend (messages read
|
|
314
314
|
* 404'd) — deleted or never visible to this agent. Message-triggered wakes
|
|
315
315
|
* check this and skip the LLM instead of reasoning over a fabricated empty
|
|
316
|
-
* history.
|
|
317
|
-
*
|
|
316
|
+
* history. Only gates message wakes. A bare agreementId as sessionId also
|
|
317
|
+
* trips it (ZIG-975) — that is a mis-keyed lane, not a legitimate task lane;
|
|
318
|
+
* task wakes should key on the agreement's origin/notification chat.
|
|
318
319
|
*/
|
|
319
320
|
chatMissing?: boolean;
|
|
320
321
|
/** Index signature so PromptBuilder's `ServerContext` can accept it directly. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Agent framework SDK for building autonomous agents on the Ziggs platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@anthropic-ai/claude-agent-sdk": "^0.3.204",
|
|
27
27
|
"@anthropic-ai/sdk": "^0.110.0",
|
|
28
28
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
29
|
-
"@ziggs-ai/api-client": "^0.
|
|
29
|
+
"@ziggs-ai/api-client": "^0.6.0",
|
|
30
30
|
"ajv": "^8.17.1",
|
|
31
31
|
"dotenv": "^17.2.3",
|
|
32
32
|
"openai": "^4.0.0",
|