@ziggs-ai/agent-sdk 0.1.11 → 0.2.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 +14 -0
- package/README.md +41 -2
- package/dist/AgentHost.d.ts +201 -0
- package/dist/AgentHost.js +652 -0
- package/dist/adapters/AnthropicAdapter.d.ts +39 -0
- package/dist/adapters/AnthropicAdapter.js +200 -0
- package/dist/adapters/McpAdapter.d.ts +199 -0
- package/dist/adapters/McpAdapter.js +468 -0
- package/dist/adapters/OpenAIAdapter.d.ts +26 -0
- package/dist/adapters/OpenAIAdapter.js +158 -0
- package/dist/adapters/index.js +2 -0
- package/dist/agent/Agent.d.ts +78 -0
- package/dist/agent/Agent.js +58 -0
- package/dist/agent/ClaudeSdkAgent.d.ts +38 -0
- package/dist/agent/ClaudeSdkAgent.js +322 -0
- package/dist/agent/claudeCognition.d.ts +67 -0
- package/dist/agent/claudeCognition.js +103 -0
- package/dist/agent/claudeSdkProtocol.d.ts +11 -0
- package/dist/agent/claudeSdkProtocol.js +27 -0
- package/dist/agent/claudeSdkTools.d.ts +19 -0
- package/dist/agent/claudeSdkTools.js +57 -0
- package/dist/agent/hostedAgentConnection.d.ts +15 -0
- package/dist/agent/hostedAgentConnection.js +29 -0
- package/dist/agent/toolManagerToSdkMcp.d.ts +12 -0
- package/dist/agent/toolManagerToSdkMcp.js +123 -0
- package/dist/brain/index.d.ts +50 -0
- package/dist/brain/index.js +45 -0
- package/dist/cognition/validateContext.d.ts +11 -0
- package/dist/cognition/validateContext.js +117 -0
- package/dist/context/applyEffects.d.ts +2 -0
- package/dist/context/applyEffects.js +89 -0
- package/dist/context/batch.d.ts +2 -0
- package/dist/context/batch.js +18 -0
- package/dist/context/classifyEnvelope.d.ts +1 -0
- package/dist/context/classifyEnvelope.js +58 -0
- package/dist/context/routingLabels.d.ts +4 -0
- package/dist/context/routingLabels.js +48 -0
- package/dist/defineAgent.d.ts +14 -0
- package/dist/defineAgent.js +68 -0
- package/dist/formatters/AgreementFormatter.d.ts +18 -0
- package/dist/formatters/AgreementFormatter.js +130 -0
- package/dist/formatters/HistoryFormatter.d.ts +26 -0
- package/dist/formatters/HistoryFormatter.js +173 -0
- package/dist/formatters/index.js +2 -0
- package/{src/index.ts → dist/index.d.ts} +13 -53
- package/dist/index.js +66 -0
- package/dist/ingress/normalizeIncoming.d.ts +65 -0
- package/dist/ingress/normalizeIncoming.js +88 -0
- package/dist/memory/MemoryStore.d.ts +55 -0
- package/dist/memory/MemoryStore.js +78 -0
- package/dist/pricing/fleetDefaults.d.ts +46 -0
- package/dist/pricing/fleetDefaults.js +168 -0
- package/dist/pricing/fleetEvalFree.d.ts +7 -0
- package/dist/pricing/fleetEvalFree.js +24 -0
- package/dist/pricing/fleetFreeTierA.gen.d.ts +6 -0
- package/{src/pricing/fleetFreeTierA.gen.ts → dist/pricing/fleetFreeTierA.gen.js} +5 -6
- package/dist/pricing/fleetTierByAgentId.gen.d.ts +7 -0
- package/dist/pricing/fleetTierByAgentId.gen.js +768 -0
- package/dist/runtime/AgentMachine.d.ts +143 -0
- package/dist/runtime/AgentMachine.js +400 -0
- package/dist/runtime/PromptBuilder.d.ts +96 -0
- package/dist/runtime/PromptBuilder.js +439 -0
- package/dist/runtime/bootstrapCtx.d.ts +18 -0
- package/dist/runtime/bootstrapCtx.js +37 -0
- package/dist/runtime/buildOutcome.d.ts +68 -0
- package/dist/runtime/buildOutcome.js +464 -0
- package/dist/runtime/defaults.d.ts +54 -0
- package/dist/runtime/defaults.js +47 -0
- package/dist/runtime/deriveRespondsToProposals.d.ts +9 -0
- package/dist/runtime/deriveRespondsToProposals.js +38 -0
- package/dist/runtime/kickoff.d.ts +15 -0
- package/dist/runtime/kickoff.js +112 -0
- package/dist/runtime/runMechanical.d.ts +25 -0
- package/dist/runtime/runMechanical.js +74 -0
- package/dist/runtime/runTurn.d.ts +63 -0
- package/dist/runtime/runTurn.js +800 -0
- package/dist/runtime/validateWorkflow.d.ts +17 -0
- package/dist/runtime/validateWorkflow.js +209 -0
- package/dist/server/ConnectionPool.d.ts +68 -0
- package/dist/server/ConnectionPool.js +166 -0
- package/dist/server/EventQueue.d.ts +33 -0
- package/dist/server/EventQueue.js +98 -0
- package/dist/server/InboxCatchUp.d.ts +24 -0
- package/dist/server/InboxCatchUp.js +213 -0
- package/dist/server/OutboxBuffer.d.ts +33 -0
- package/dist/server/OutboxBuffer.js +68 -0
- package/dist/server/SeenMessages.d.ts +13 -0
- package/dist/server/SeenMessages.js +31 -0
- package/dist/server/StateTimers.d.ts +34 -0
- package/dist/server/StateTimers.js +70 -0
- package/dist/server/ZiggsEffectHandler.d.ts +79 -0
- package/dist/server/ZiggsEffectHandler.js +319 -0
- package/dist/server/agreements/AgreementService.d.ts +50 -0
- package/dist/server/agreements/AgreementService.js +85 -0
- package/dist/server/createHealthServer.d.ts +7 -0
- package/dist/server/createHealthServer.js +75 -0
- package/dist/server/proactive/ProactiveTrigger.d.ts +33 -0
- package/dist/server/proactive/ProactiveTrigger.js +71 -0
- package/dist/server/runLauncher.d.ts +28 -0
- package/dist/server/runLauncher.js +93 -0
- package/dist/server/tasks/TaskService.d.ts +25 -0
- package/dist/server/tasks/TaskService.js +103 -0
- package/dist/server/tasks/index.js +1 -0
- package/dist/server/telemetryIngest.d.ts +24 -0
- package/dist/server/telemetryIngest.js +62 -0
- package/dist/server/tools/index.d.ts +24 -0
- package/{src/server/tools/index.ts → dist/server/tools/index.js} +4 -24
- package/dist/server/tools/tier1/protocolRunner.d.ts +39 -0
- package/dist/server/tools/tier1/protocolRunner.js +288 -0
- package/dist/server/tools/tier1/protocolTools.d.ts +12 -0
- package/dist/server/tools/tier1/protocolTools.js +37 -0
- package/dist/server/tools/tier2/connectionTools.d.ts +4 -0
- package/dist/server/tools/tier2/connectionTools.js +63 -0
- package/dist/server/tools/tier2/contextTools.d.ts +4 -0
- package/dist/server/tools/tier2/contextTools.js +46 -0
- package/dist/server/tools/tier2/discoveryTools.d.ts +4 -0
- package/dist/server/tools/tier2/discoveryTools.js +25 -0
- package/dist/server/tools/tier2/marketplaceTools.d.ts +3 -0
- package/dist/server/tools/tier2/marketplaceTools.js +22 -0
- package/dist/server/tools/tier2/paymentTools.d.ts +12 -0
- package/dist/server/tools/tier2/paymentTools.js +165 -0
- package/dist/server/ziggsconnect/ZiggsConnectClient.d.ts +35 -0
- package/dist/server/ziggsconnect/ZiggsConnectClient.js +95 -0
- package/dist/server/ziggscontext/ZiggsContextClient.d.ts +48 -0
- package/dist/server/ziggscontext/ZiggsContextClient.js +90 -0
- package/dist/server/ziggspay/ZiggsPayClient.d.ts +82 -0
- package/dist/server/ziggspay/ZiggsPayClient.js +188 -0
- package/dist/shared/ids.d.ts +1 -0
- package/dist/shared/ids.js +3 -0
- package/dist/shared/runtimeLog.d.ts +18 -0
- package/dist/shared/runtimeLog.js +68 -0
- package/dist/shared/types.d.ts +22 -0
- package/dist/shared/types.js +23 -0
- package/dist/tasks/protocolRegistry.d.ts +16 -0
- package/dist/tasks/protocolRegistry.js +20 -0
- package/dist/tools/ToolManager.d.ts +12 -0
- package/dist/tools/ToolManager.js +74 -0
- package/dist/tools/ToolProvider.d.ts +6 -0
- package/dist/tools/ToolProvider.js +21 -0
- package/dist/tools/defineTool.d.ts +27 -0
- package/dist/tools/defineTool.js +62 -0
- package/{src/tools/index.ts → dist/tools/index.d.ts} +0 -1
- package/dist/tools/index.js +6 -0
- package/dist/tools/recordReport.d.ts +41 -0
- package/dist/tools/recordReport.js +30 -0
- package/dist/types.d.ts +466 -0
- package/dist/types.js +7 -0
- package/dist/utils/jsonExtractor.d.ts +2 -0
- package/dist/utils/jsonExtractor.js +111 -0
- package/package.json +17 -7
- package/src/AgentHost.ts +0 -545
- package/src/adapters/AnthropicAdapter.ts +0 -206
- package/src/adapters/McpAdapter.ts +0 -348
- package/src/adapters/OpenAIAdapter.ts +0 -187
- package/src/agent/Agent.ts +0 -104
- package/src/cognition/validateContext.ts +0 -95
- package/src/context/applyEffects.ts +0 -80
- package/src/context/batch.ts +0 -19
- package/src/context/classifyEnvelope.ts +0 -38
- package/src/context/routingLabels.ts +0 -46
- package/src/defineAgent.ts +0 -70
- package/src/formatters/AgreementFormatter.ts +0 -111
- package/src/formatters/HistoryFormatter.ts +0 -172
- package/src/ingress/normalizeIncoming.ts +0 -162
- package/src/memory/MemoryStore.ts +0 -104
- package/src/pricing/fleetDefaults.ts +0 -225
- package/src/pricing/fleetEvalFree.ts +0 -24
- package/src/pricing/fleetTierByAgentId.gen.ts +0 -775
- package/src/runtime/AgentMachine.ts +0 -402
- package/src/runtime/PromptBuilder.ts +0 -485
- package/src/runtime/buildOutcome.ts +0 -563
- package/src/runtime/defaults.ts +0 -75
- package/src/runtime/kickoff.ts +0 -117
- package/src/runtime/runTurn.ts +0 -813
- package/src/runtime/validateWorkflow.ts +0 -202
- package/src/server/ConnectionPool.ts +0 -206
- package/src/server/EventQueue.ts +0 -133
- package/src/server/InboxCatchUp.ts +0 -254
- package/src/server/OutboxBuffer.ts +0 -90
- package/src/server/SeenMessages.ts +0 -27
- package/src/server/StateTimers.ts +0 -85
- package/src/server/ZiggsEffectHandler.ts +0 -418
- package/src/server/agreements/AgreementService.ts +0 -118
- package/src/server/createHealthServer.ts +0 -85
- package/src/server/proactive/ProactiveTrigger.ts +0 -83
- package/src/server/runLauncher.ts +0 -146
- package/src/server/tasks/TaskService.ts +0 -110
- package/src/server/telemetryIngest.ts +0 -91
- package/src/server/tools/tier1/protocolRunner.ts +0 -144
- package/src/server/tools/tier1/protocolTools.ts +0 -99
- package/src/server/tools/tier2/connectionTools.ts +0 -75
- package/src/server/tools/tier2/contextTools.ts +0 -63
- package/src/server/tools/tier2/discoveryTools.ts +0 -34
- package/src/server/tools/tier2/marketplaceTools.ts +0 -27
- package/src/server/tools/tier2/paymentTools.ts +0 -170
- package/src/server/ziggsconnect/ZiggsConnectClient.ts +0 -126
- package/src/server/ziggscontext/ZiggsContextClient.ts +0 -129
- package/src/server/ziggspay/ZiggsPayClient.ts +0 -193
- package/src/shared/ids.ts +0 -3
- package/src/shared/runtimeLog.ts +0 -72
- package/src/shared/types.ts +0 -29
- package/src/tasks/protocolRegistry.ts +0 -25
- package/src/tools/ToolManager.ts +0 -95
- package/src/tools/ToolProvider.ts +0 -19
- package/src/tools/defineTool.ts +0 -90
- package/src/tools/recordReport.ts +0 -82
- package/src/types.ts +0 -456
- package/src/utils/jsonExtractor.ts +0 -100
- /package/{src/adapters/index.ts → dist/adapters/index.d.ts} +0 -0
- /package/{src/formatters/index.ts → dist/formatters/index.d.ts} +0 -0
- /package/{src/server/tasks/index.ts → dist/server/tasks/index.d.ts} +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ziggs-ai/agent-sdk public surface.
|
|
3
|
+
*
|
|
4
|
+
* Foundation:
|
|
5
|
+
* • Outcome union — discriminated, hybrid (closed core + extension)
|
|
6
|
+
* • Workflow shape — explicit kind: 'parked' | 'thinking' | 'mechanical'
|
|
7
|
+
* • Visible defaults — thinkingDefaults({ initial }) spread by author
|
|
8
|
+
* • Validation at load — defineAgent throws on hard problems, warns on soft
|
|
9
|
+
*/
|
|
10
|
+
export { defineAgent } from './defineAgent.js';
|
|
11
|
+
export { createMcpAgent, resolveZiggsGatewayTarget, wrapGatewayFetch, ZiggsGatewayError } from './adapters/McpAdapter.js';
|
|
12
|
+
export { AgentHost, createAgent, createAgentPool, DEFAULT_MODEL } from './AgentHost.js';
|
|
13
|
+
export { Agent } from './agent/Agent.js';
|
|
14
|
+
export { ClaudeSdkAgent } from './agent/ClaudeSdkAgent.js';
|
|
15
|
+
export { ziggsBrain, claudeBrain, isBrainSelection, isClaudeCognition } from './brain/index.js';
|
|
16
|
+
export { createZiggsEffectHandler } from './server/ZiggsEffectHandler.js';
|
|
17
|
+
export { EventQueue } from './server/EventQueue.js';
|
|
18
|
+
export { StateTimers } from './server/StateTimers.js';
|
|
19
|
+
export { OutboxBuffer } from './server/OutboxBuffer.js';
|
|
20
|
+
export { normalizeIncomingEvent } from './ingress/normalizeIncoming.js';
|
|
21
|
+
// Runtime primitives
|
|
22
|
+
export { AgentMachine } from './runtime/AgentMachine.js';
|
|
23
|
+
export { runTurn } from './runtime/runTurn.js';
|
|
24
|
+
export { runMechanical } from './runtime/runMechanical.js';
|
|
25
|
+
export { PromptBuilder } from './runtime/PromptBuilder.js';
|
|
26
|
+
export { thinkingDefaults, defineThinkingState, defineMechanicalState, DEFAULT_WAIT_PROMPT } from './runtime/defaults.js';
|
|
27
|
+
export { KICKOFF_STATE, injectKickoffDefault, buildKickoffState } from './runtime/kickoff.js';
|
|
28
|
+
export { validateWorkflow, WorkflowValidationError } from './runtime/validateWorkflow.js';
|
|
29
|
+
export { deriveRespondsToProposals, statesRespondToProposals, } from './runtime/deriveRespondsToProposals.js';
|
|
30
|
+
export { outcomeFromEvent, outcomeFromActionResult, applyOutcomeToCtx } from './runtime/buildOutcome.js';
|
|
31
|
+
export { default } from './AgentHost.js';
|
|
32
|
+
// ── Supporting modules ──────────────────────────────────────────────────────
|
|
33
|
+
export { validateContext, ContextWarning } from './cognition/validateContext.js';
|
|
34
|
+
export { runLauncher } from './server/runLauncher.js';
|
|
35
|
+
export { ConnectionPool } from './server/ConnectionPool.js';
|
|
36
|
+
export { createHealthServer } from './server/createHealthServer.js';
|
|
37
|
+
export { TaskService } from './server/tasks/TaskService.js';
|
|
38
|
+
export { AgreementService } from './server/agreements/AgreementService.js';
|
|
39
|
+
export { ToolManager } from './tools/ToolManager.js';
|
|
40
|
+
export { ToolProvider } from './tools/ToolProvider.js';
|
|
41
|
+
export { defineTool } from './tools/defineTool.js';
|
|
42
|
+
export { recordReport } from './tools/recordReport.js';
|
|
43
|
+
export { OpenAIAdapter } from './adapters/OpenAIAdapter.js';
|
|
44
|
+
export { extractJSON, safeParseJSON } from './utils/jsonExtractor.js';
|
|
45
|
+
export { HistoryFormatter, historyFormatter, AgreementFormatter, agreementFormatter } from './formatters/index.js';
|
|
46
|
+
export { ProactiveTrigger } from './server/proactive/ProactiveTrigger.js';
|
|
47
|
+
export { ZiggsPayClient, createZiggsPayClient } from './server/ziggspay/ZiggsPayClient.js';
|
|
48
|
+
export { ZiggsConnectClient, createZiggsConnectClient } from './server/ziggsconnect/ZiggsConnectClient.js';
|
|
49
|
+
export { ZiggsContextClient } from './server/ziggscontext/ZiggsContextClient.js';
|
|
50
|
+
// All agent tool bundles live under server/tools/ (tier1 = protocol grammar,
|
|
51
|
+
// tier2 = opt-in HTTP capability bundles). Single home: server/tools/index.ts.
|
|
52
|
+
export {
|
|
53
|
+
// Tier 1 — protocol grammar (framework-managed via taskTools).
|
|
54
|
+
PROTOCOL_TOOLS, agreementProposeTool, agreementSubcontractTool, agreementRespondTool, agreementCounterProposalTool, agreementCheckProposalTool, taskSpawnTool, taskUpdateTool, taskUpdatePlanStepTool, dispatchProtocolOp,
|
|
55
|
+
// Tier 2 — opt-in capability bundles (spread into `tools:`).
|
|
56
|
+
PAYMENT_TOOLS, paymentBalanceTool, paymentTransferTool, paymentHoldTool, paymentReleaseTool, paymentResolveWalletTool, CONNECTION_TOOLS, connectionProxyTool, connectionListGrantsTool, DISCOVERY_TOOLS, agentSearchTool, agentGetTool, MARKETPLACE_TOOLS, marketplaceViewTool, } from './server/tools/index.js';
|
|
57
|
+
export { PROTOCOL_TOOL_NAMES, PROTOCOL_TOOL_TO_OPERATION, mapProtocolToolToOperation, isProtocolToolName } from './tasks/protocolRegistry.js';
|
|
58
|
+
export { InMemoryStore, FileMemoryStore } from './memory/MemoryStore.js';
|
|
59
|
+
export { classifyIncomingEvent } from './context/classifyEnvelope.js';
|
|
60
|
+
export { buildContextUpdates, CONTEXT_RESET } from './context/applyEffects.js';
|
|
61
|
+
export { getBatchEvents, isTaskResultRelevantToAgent } from './context/batch.js';
|
|
62
|
+
export { classifyWorkflowEvent, findTaskResult, unwrapBatchEvent, findIncomingTaskResult } from './context/routingLabels.js';
|
|
63
|
+
export { WebSocketClient, MessagesClient, ArtifactsClient, AgentSearchClient, getBackendUrl, getWebSocketUrl, } from '@ziggs-ai/api-client';
|
|
64
|
+
export { runInboxCatchUp } from './server/InboxCatchUp.js';
|
|
65
|
+
export { SeenMessages } from './server/SeenMessages.js';
|
|
66
|
+
export { runtimeLog, resetRuntimeLogLevelCache } from './shared/runtimeLog.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface NormalizedEvent {
|
|
2
|
+
chatId: string | null;
|
|
3
|
+
event: {
|
|
4
|
+
senderId?: string;
|
|
5
|
+
senderType?: string;
|
|
6
|
+
receiverId?: string;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
type: 'task_result' | 'message' | 'agreement_lifecycle';
|
|
9
|
+
operation?: string;
|
|
10
|
+
agreementId?: string;
|
|
11
|
+
result?: unknown;
|
|
12
|
+
text?: string;
|
|
13
|
+
};
|
|
14
|
+
shouldProcess: boolean;
|
|
15
|
+
reason: string | null;
|
|
16
|
+
}
|
|
17
|
+
interface WireParties {
|
|
18
|
+
creator?: string;
|
|
19
|
+
provider?: string;
|
|
20
|
+
payer?: string;
|
|
21
|
+
proposedTo?: string;
|
|
22
|
+
}
|
|
23
|
+
interface WireTask {
|
|
24
|
+
taskId?: string;
|
|
25
|
+
agentId?: string;
|
|
26
|
+
executorId?: string;
|
|
27
|
+
payerId?: string;
|
|
28
|
+
proposedTo?: string;
|
|
29
|
+
createdBy?: string;
|
|
30
|
+
parentTaskId?: string;
|
|
31
|
+
state?: string;
|
|
32
|
+
proposal?: unknown;
|
|
33
|
+
agreement?: {
|
|
34
|
+
parties?: WireParties;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface WireMetadata {
|
|
38
|
+
chatId?: string;
|
|
39
|
+
chat_id?: string;
|
|
40
|
+
entryType?: string;
|
|
41
|
+
content_type?: string;
|
|
42
|
+
contentType?: string;
|
|
43
|
+
receiverId?: string;
|
|
44
|
+
operation?: string;
|
|
45
|
+
agreementId?: string;
|
|
46
|
+
sender?: {
|
|
47
|
+
id?: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
};
|
|
50
|
+
receiver?: {
|
|
51
|
+
id?: string;
|
|
52
|
+
};
|
|
53
|
+
to?: {
|
|
54
|
+
id?: string;
|
|
55
|
+
};
|
|
56
|
+
task?: WireTask;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
interface NormalizeArgs {
|
|
60
|
+
text: string;
|
|
61
|
+
metadata?: WireMetadata;
|
|
62
|
+
ownAgentId?: string | null;
|
|
63
|
+
}
|
|
64
|
+
export declare function normalizeIncomingEvent({ text, metadata, ownAgentId }: NormalizeArgs): NormalizedEvent;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { OPEN_AGREEMENT_TARGET } from '@ziggs-ai/api-client';
|
|
2
|
+
/** Backend wire operations that map to FSM `proposal-resolved`. */
|
|
3
|
+
const PROPOSAL_RESOLVED_OPERATIONS = new Set([
|
|
4
|
+
'proposal_approved',
|
|
5
|
+
'proposal_rejected',
|
|
6
|
+
'proposal_approved_execute',
|
|
7
|
+
]);
|
|
8
|
+
function normalizeChatId(metadata) {
|
|
9
|
+
return metadata.chatId || metadata.chat_id || null;
|
|
10
|
+
}
|
|
11
|
+
function normalizeReceiverId(metadata, taskData) {
|
|
12
|
+
return metadata.receiver?.id || metadata.receiverId || metadata.to?.id || taskData?.executorId || taskData?.proposedTo || null;
|
|
13
|
+
}
|
|
14
|
+
function isTaskRelated(metadata, taskData) {
|
|
15
|
+
if (!taskData?.taskId)
|
|
16
|
+
return false;
|
|
17
|
+
const entryType = metadata.entryType || 'message';
|
|
18
|
+
const contentType = metadata.content_type || metadata.contentType || 'text';
|
|
19
|
+
return (entryType === 'notification' || entryType === 'task_history'
|
|
20
|
+
|| contentType === 'task' || contentType === 'task_update'
|
|
21
|
+
|| Boolean(taskData.state || taskData.proposal || taskData.parentTaskId || taskData.executorId || taskData.agentId || taskData.payerId || taskData.createdBy));
|
|
22
|
+
}
|
|
23
|
+
function isRelevantForAgent(ids, ownAgentId) {
|
|
24
|
+
if (!ownAgentId)
|
|
25
|
+
return true;
|
|
26
|
+
return ids.includes(ownAgentId) || ids.includes(OPEN_AGREEMENT_TARGET);
|
|
27
|
+
}
|
|
28
|
+
function isAgreementLifecycleNotification(metadata) {
|
|
29
|
+
const entryType = metadata.entryType || 'message';
|
|
30
|
+
const operation = metadata.operation;
|
|
31
|
+
return (entryType === 'notification' &&
|
|
32
|
+
typeof operation === 'string' &&
|
|
33
|
+
PROPOSAL_RESOLVED_OPERATIONS.has(operation));
|
|
34
|
+
}
|
|
35
|
+
export function normalizeIncomingEvent({ text, metadata = {}, ownAgentId = null }) {
|
|
36
|
+
const taskData = metadata.task || null;
|
|
37
|
+
const chatId = normalizeChatId(metadata);
|
|
38
|
+
const receiverId = normalizeReceiverId(metadata, taskData);
|
|
39
|
+
const senderType = metadata.sender?.type ? String(metadata.sender.type).toUpperCase() : undefined;
|
|
40
|
+
const base = {
|
|
41
|
+
senderId: metadata.sender?.id,
|
|
42
|
+
senderType,
|
|
43
|
+
receiverId: receiverId || undefined,
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
};
|
|
46
|
+
if (isAgreementLifecycleNotification(metadata)) {
|
|
47
|
+
const relevant = !ownAgentId ||
|
|
48
|
+
!receiverId ||
|
|
49
|
+
receiverId === ownAgentId ||
|
|
50
|
+
receiverId === OPEN_AGREEMENT_TARGET;
|
|
51
|
+
const agreementId = typeof metadata.agreementId === 'string' ? metadata.agreementId : '';
|
|
52
|
+
return {
|
|
53
|
+
chatId,
|
|
54
|
+
event: {
|
|
55
|
+
...base,
|
|
56
|
+
type: 'agreement_lifecycle',
|
|
57
|
+
operation: metadata.operation,
|
|
58
|
+
agreementId,
|
|
59
|
+
text,
|
|
60
|
+
},
|
|
61
|
+
shouldProcess: relevant,
|
|
62
|
+
reason: relevant ? null : 'message_not_targeted_to_agent',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (isTaskRelated(metadata, taskData)) {
|
|
66
|
+
const receiverFromMeta = metadata.receiver?.id || metadata.receiverId || null;
|
|
67
|
+
const parties = taskData.agreement?.parties ?? {};
|
|
68
|
+
const candidateIds = [
|
|
69
|
+
parties.creator, parties.provider, parties.payer, parties.proposedTo,
|
|
70
|
+
taskData.agentId, taskData.executorId, taskData.payerId, taskData.proposedTo, taskData.createdBy,
|
|
71
|
+
receiverFromMeta,
|
|
72
|
+
].filter(Boolean);
|
|
73
|
+
const relevant = isRelevantForAgent(candidateIds, ownAgentId);
|
|
74
|
+
return {
|
|
75
|
+
chatId,
|
|
76
|
+
event: { ...base, type: 'task_result', result: taskData, text },
|
|
77
|
+
shouldProcess: relevant,
|
|
78
|
+
reason: relevant ? null : 'task_not_targeted_to_agent',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const relevant = !ownAgentId || !receiverId || receiverId === ownAgentId || receiverId === OPEN_AGREEMENT_TARGET;
|
|
82
|
+
return {
|
|
83
|
+
chatId,
|
|
84
|
+
event: { ...base, type: 'message', text },
|
|
85
|
+
shouldProcess: relevant,
|
|
86
|
+
reason: relevant ? null : 'message_not_targeted_to_agent',
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-private long-term memory.
|
|
3
|
+
*
|
|
4
|
+
* This is the SDK's contract; the *storage* is operator-provided. The agent
|
|
5
|
+
* picks the key shape (often `counterparty:<id>`, sometimes `agreement:<id>:notes`,
|
|
6
|
+
* etc.) — the SDK does not enforce one.
|
|
7
|
+
*
|
|
8
|
+
* Reference implementations: `InMemoryStore` (default; non-durable) and
|
|
9
|
+
* `FileMemoryStore` (single JSON file; useful for local dev). Anything
|
|
10
|
+
* production-grade (sqlite, redis, postgres, …) is operator-owned.
|
|
11
|
+
*
|
|
12
|
+
* Aligns with the project's "agents are third-party" framing: an agent's
|
|
13
|
+
* private notes are its own concern, not the backend's.
|
|
14
|
+
*/
|
|
15
|
+
export interface MemoryStore {
|
|
16
|
+
get(key: string): Promise<unknown | undefined>;
|
|
17
|
+
put(key: string, value: unknown): Promise<void>;
|
|
18
|
+
list(prefix: string): Promise<{
|
|
19
|
+
key: string;
|
|
20
|
+
value: unknown;
|
|
21
|
+
}[]>;
|
|
22
|
+
delete?(key: string): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** Non-durable reference impl. Per-process; lost on restart. */
|
|
25
|
+
export declare class InMemoryStore implements MemoryStore {
|
|
26
|
+
private readonly store;
|
|
27
|
+
get(key: string): Promise<unknown | undefined>;
|
|
28
|
+
put(key: string, value: unknown): Promise<void>;
|
|
29
|
+
list(prefix: string): Promise<{
|
|
30
|
+
key: string;
|
|
31
|
+
value: unknown;
|
|
32
|
+
}[]>;
|
|
33
|
+
delete(key: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Single-file JSON store. Reads on startup, writes on every put — fine for
|
|
37
|
+
* local dev and example agents; not for production (no concurrency control,
|
|
38
|
+
* no atomicity). Operators with serious durability needs ship their own
|
|
39
|
+
* `MemoryStore` (sqlite, redis, …) and pass it via `defineAgent({ memory })`.
|
|
40
|
+
*/
|
|
41
|
+
export declare class FileMemoryStore implements MemoryStore {
|
|
42
|
+
private readonly path;
|
|
43
|
+
private cache;
|
|
44
|
+
private loading;
|
|
45
|
+
constructor(path: string);
|
|
46
|
+
private _ensureLoaded;
|
|
47
|
+
private _flush;
|
|
48
|
+
get(key: string): Promise<unknown | undefined>;
|
|
49
|
+
put(key: string, value: unknown): Promise<void>;
|
|
50
|
+
list(prefix: string): Promise<{
|
|
51
|
+
key: string;
|
|
52
|
+
value: unknown;
|
|
53
|
+
}[]>;
|
|
54
|
+
delete(key: string): Promise<void>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Non-durable reference impl. Per-process; lost on restart. */
|
|
2
|
+
export class InMemoryStore {
|
|
3
|
+
store = new Map();
|
|
4
|
+
async get(key) {
|
|
5
|
+
return this.store.get(key);
|
|
6
|
+
}
|
|
7
|
+
async put(key, value) {
|
|
8
|
+
this.store.set(key, value);
|
|
9
|
+
}
|
|
10
|
+
async list(prefix) {
|
|
11
|
+
const out = [];
|
|
12
|
+
for (const [k, v] of this.store) {
|
|
13
|
+
if (k.startsWith(prefix))
|
|
14
|
+
out.push({ key: k, value: v });
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
async delete(key) {
|
|
19
|
+
this.store.delete(key);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Single-file JSON store. Reads on startup, writes on every put — fine for
|
|
24
|
+
* local dev and example agents; not for production (no concurrency control,
|
|
25
|
+
* no atomicity). Operators with serious durability needs ship their own
|
|
26
|
+
* `MemoryStore` (sqlite, redis, …) and pass it via `defineAgent({ memory })`.
|
|
27
|
+
*/
|
|
28
|
+
export class FileMemoryStore {
|
|
29
|
+
path;
|
|
30
|
+
cache = null;
|
|
31
|
+
loading = null;
|
|
32
|
+
constructor(path) {
|
|
33
|
+
this.path = path;
|
|
34
|
+
}
|
|
35
|
+
async _ensureLoaded() {
|
|
36
|
+
if (this.cache)
|
|
37
|
+
return;
|
|
38
|
+
if (!this.loading) {
|
|
39
|
+
this.loading = (async () => {
|
|
40
|
+
try {
|
|
41
|
+
const fs = await import('fs/promises');
|
|
42
|
+
const txt = await fs.readFile(this.path, 'utf-8');
|
|
43
|
+
this.cache = JSON.parse(txt);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
this.cache = {};
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
}
|
|
50
|
+
await this.loading;
|
|
51
|
+
}
|
|
52
|
+
async _flush() {
|
|
53
|
+
if (!this.cache)
|
|
54
|
+
return;
|
|
55
|
+
const fs = await import('fs/promises');
|
|
56
|
+
await fs.writeFile(this.path, JSON.stringify(this.cache, null, 2), 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
async get(key) {
|
|
59
|
+
await this._ensureLoaded();
|
|
60
|
+
return this.cache[key];
|
|
61
|
+
}
|
|
62
|
+
async put(key, value) {
|
|
63
|
+
await this._ensureLoaded();
|
|
64
|
+
this.cache[key] = value;
|
|
65
|
+
await this._flush();
|
|
66
|
+
}
|
|
67
|
+
async list(prefix) {
|
|
68
|
+
await this._ensureLoaded();
|
|
69
|
+
return Object.entries(this.cache)
|
|
70
|
+
.filter(([k]) => k.startsWith(prefix))
|
|
71
|
+
.map(([key, value]) => ({ key, value }));
|
|
72
|
+
}
|
|
73
|
+
async delete(key) {
|
|
74
|
+
await this._ensureLoaded();
|
|
75
|
+
delete this.cache[key];
|
|
76
|
+
await this._flush();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIG-368 — default paid pricing for Ziggs-operated (first-party) agents.
|
|
3
|
+
* Prices are in wallet cents (1 ZIG = 100 cents).
|
|
4
|
+
*/
|
|
5
|
+
import { type FleetPricingTier } from './fleetTierByAgentId.gen.js';
|
|
6
|
+
export declare const ZIGGS_OPERATOR_CUT_BPS = 1000;
|
|
7
|
+
export declare const TIER_PRICE_CENTS: Record<FleetPricingTier, number>;
|
|
8
|
+
export declare function resolveFleetTier(agentId: string): FleetPricingTier | null;
|
|
9
|
+
export declare function isFirstPartyFleetAgent(agentId: string): boolean;
|
|
10
|
+
export declare function tierPriceCents(tier: FleetPricingTier): number;
|
|
11
|
+
export declare function isZiggsOrchestrator(agentId: string): boolean;
|
|
12
|
+
export declare function isFreeAllowlistedExecutor(executorId: string, description?: string | null): boolean;
|
|
13
|
+
export declare function resolveDefaultPriceCentsForExecutor(executorId: string, description?: string | null): number | null;
|
|
14
|
+
export interface ProtocolPricingPayload {
|
|
15
|
+
price?: number | null;
|
|
16
|
+
description?: string;
|
|
17
|
+
agreementDescription?: string;
|
|
18
|
+
proposedTo?: string;
|
|
19
|
+
providerId?: string;
|
|
20
|
+
executorId?: string;
|
|
21
|
+
parentAgreementId?: string;
|
|
22
|
+
parentTaskId?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Apply ZIG-368 defaults when `price` is omitted (null/undefined).
|
|
27
|
+
* Explicit `price: 0` is kept (free-on-purpose).
|
|
28
|
+
*/
|
|
29
|
+
export declare function applyFleetAgreementPricing(operation: 'agreement-propose' | 'agreement-subcontract', payload: ProtocolPricingPayload, actingAgentId: string): ProtocolPricingPayload;
|
|
30
|
+
/**
|
|
31
|
+
* Default tier price when a fleet agent counters without an explicit `price`.
|
|
32
|
+
*
|
|
33
|
+
* Generic over the payload shape so the precise field types of the caller's
|
|
34
|
+
* payload survive the round-trip — this helper only ever sets `price`, so a
|
|
35
|
+
* richer input type (e.g. protocolRunner's `ProtocolPayload`) must come back
|
|
36
|
+
* out unwidened by `ProtocolPricingPayload`'s `[key: string]: unknown` index.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyFleetCounterPricing<T extends ProtocolPricingPayload>(payload: T, actingAgentId: string): T;
|
|
39
|
+
/** User or agent direct-create / marketplace: default from provider specialist. */
|
|
40
|
+
export declare function resolveDefaultPriceForProvider(providerId: string, description?: string | null, explicitPrice?: number | null): number | null;
|
|
41
|
+
/**
|
|
42
|
+
* Infer fleet actor when tool context omits agentId (ZIG-368 safety net).
|
|
43
|
+
*/
|
|
44
|
+
export declare function inferFleetPricingActorId(payload: ProtocolPricingPayload): string | null;
|
|
45
|
+
/** Apply fleet defaults with optional acting agent (falls back to payload inference). */
|
|
46
|
+
export declare function applyFleetPricingForProtocol(operation: 'agreement-propose' | 'agreement-subcontract', payload: ProtocolPricingPayload, actingAgentId: string | null): ProtocolPricingPayload;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIG-368 — default paid pricing for Ziggs-operated (first-party) agents.
|
|
3
|
+
* Prices are in wallet cents (1 ZIG = 100 cents).
|
|
4
|
+
*/
|
|
5
|
+
import { FLEET_TIER_BY_AGENT_ID } from './fleetTierByAgentId.gen.js';
|
|
6
|
+
import { FREE_TIER_A_AGENT_IDS } from './fleetFreeTierA.gen.js';
|
|
7
|
+
import { isEvalFreeExecutor } from './fleetEvalFree.js';
|
|
8
|
+
export const ZIGGS_OPERATOR_CUT_BPS = 1000; // 10%
|
|
9
|
+
export const TIER_PRICE_CENTS = {
|
|
10
|
+
A: 200, // 2 ZIG / call
|
|
11
|
+
B: 500, // 5 ZIG / call
|
|
12
|
+
C: 1500, // 15 ZIG / job (orchestrator, charged once at top)
|
|
13
|
+
D: 100, // 1 ZIG / call (hand-written demo agents)
|
|
14
|
+
};
|
|
15
|
+
const ZIGGS_ORCHESTRATOR_IDS = new Set(['ziggs-agent']);
|
|
16
|
+
const PING_DESCRIPTION_PATTERN = /\b(ping|health\s*check|healthcheck|liveness|readiness|heartbeat)\b/i;
|
|
17
|
+
const TRIVIAL_LOOKUP_DESCRIPTION_PATTERN = /\b(what\s+time|current\s+time|local\s+time|world\s+clock|timezone|time\s+zone|weather|forecast|temperature|uv\s+index)\b/i;
|
|
18
|
+
export function resolveFleetTier(agentId) {
|
|
19
|
+
if (!agentId || typeof agentId !== 'string')
|
|
20
|
+
return null;
|
|
21
|
+
return FLEET_TIER_BY_AGENT_ID[agentId] ?? null;
|
|
22
|
+
}
|
|
23
|
+
export function isFirstPartyFleetAgent(agentId) {
|
|
24
|
+
return resolveFleetTier(agentId) != null;
|
|
25
|
+
}
|
|
26
|
+
export function tierPriceCents(tier) {
|
|
27
|
+
return TIER_PRICE_CENTS[tier];
|
|
28
|
+
}
|
|
29
|
+
export function isZiggsOrchestrator(agentId) {
|
|
30
|
+
return ZIGGS_ORCHESTRATOR_IDS.has(agentId);
|
|
31
|
+
}
|
|
32
|
+
export function isFreeAllowlistedExecutor(executorId, description) {
|
|
33
|
+
if (!executorId)
|
|
34
|
+
return false;
|
|
35
|
+
if (isEvalFreeExecutor(executorId))
|
|
36
|
+
return true;
|
|
37
|
+
if (FREE_TIER_A_AGENT_IDS.has(executorId))
|
|
38
|
+
return true;
|
|
39
|
+
if (description && PING_DESCRIPTION_PATTERN.test(description))
|
|
40
|
+
return true;
|
|
41
|
+
if (description &&
|
|
42
|
+
TRIVIAL_LOOKUP_DESCRIPTION_PATTERN.test(description) &&
|
|
43
|
+
FREE_TIER_A_AGENT_IDS.has(executorId)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
export function resolveDefaultPriceCentsForExecutor(executorId, description) {
|
|
49
|
+
if (isFreeAllowlistedExecutor(executorId, description))
|
|
50
|
+
return 0;
|
|
51
|
+
const tier = resolveFleetTier(executorId);
|
|
52
|
+
if (!tier)
|
|
53
|
+
return null;
|
|
54
|
+
return tierPriceCents(tier);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Apply ZIG-368 defaults when `price` is omitted (null/undefined).
|
|
58
|
+
* Explicit `price: 0` is kept (free-on-purpose).
|
|
59
|
+
*/
|
|
60
|
+
export function applyFleetAgreementPricing(operation, payload, actingAgentId) {
|
|
61
|
+
if (payload.price != null && payload.price !== undefined) {
|
|
62
|
+
return payload;
|
|
63
|
+
}
|
|
64
|
+
const next = { ...payload };
|
|
65
|
+
const scopeDescription = next.description ?? next.agreementDescription;
|
|
66
|
+
if (operation === 'agreement-subcontract') {
|
|
67
|
+
const executorId = String(next.executorId ?? '');
|
|
68
|
+
if (next.parentAgreementId) {
|
|
69
|
+
// Paid parent scope: no second user hold — allocate from parent budget (recordAllocation).
|
|
70
|
+
const cents = resolveDefaultPriceCentsForExecutor(executorId, scopeDescription);
|
|
71
|
+
next.price = cents ?? 0;
|
|
72
|
+
return next;
|
|
73
|
+
}
|
|
74
|
+
const cents = resolveDefaultPriceCentsForExecutor(executorId, scopeDescription);
|
|
75
|
+
if (cents != null)
|
|
76
|
+
next.price = cents;
|
|
77
|
+
return next;
|
|
78
|
+
}
|
|
79
|
+
// agreement-propose
|
|
80
|
+
if (next.parentAgreementId) {
|
|
81
|
+
return next;
|
|
82
|
+
}
|
|
83
|
+
const proposedTo = next.proposedTo != null ? String(next.proposedTo) : '';
|
|
84
|
+
const providerId = next.providerId != null ? String(next.providerId) : '';
|
|
85
|
+
// Ziggs scope proposal to human user — 15 ZIG once at top.
|
|
86
|
+
if (isZiggsOrchestrator(actingAgentId) &&
|
|
87
|
+
proposedTo &&
|
|
88
|
+
!isFirstPartyFleetAgent(proposedTo)) {
|
|
89
|
+
next.price = TIER_PRICE_CENTS.C;
|
|
90
|
+
return next;
|
|
91
|
+
}
|
|
92
|
+
// Tier C orchestrator proposing scope to a user (non-ziggs fleet orchestrators).
|
|
93
|
+
const actingTier = resolveFleetTier(actingAgentId);
|
|
94
|
+
if (actingTier === 'C' && proposedTo && !isFirstPartyFleetAgent(proposedTo)) {
|
|
95
|
+
next.price = TIER_PRICE_CENTS.C;
|
|
96
|
+
return next;
|
|
97
|
+
}
|
|
98
|
+
// Matchmaking: propose directly to a fleet specialist with tier list price.
|
|
99
|
+
const specialistId = providerId || (isFirstPartyFleetAgent(proposedTo) ? proposedTo : '');
|
|
100
|
+
if (specialistId) {
|
|
101
|
+
const cents = resolveDefaultPriceCentsForExecutor(specialistId, scopeDescription);
|
|
102
|
+
if (cents != null)
|
|
103
|
+
next.price = cents;
|
|
104
|
+
}
|
|
105
|
+
return next;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Default tier price when a fleet agent counters without an explicit `price`.
|
|
109
|
+
*
|
|
110
|
+
* Generic over the payload shape so the precise field types of the caller's
|
|
111
|
+
* payload survive the round-trip — this helper only ever sets `price`, so a
|
|
112
|
+
* richer input type (e.g. protocolRunner's `ProtocolPayload`) must come back
|
|
113
|
+
* out unwidened by `ProtocolPricingPayload`'s `[key: string]: unknown` index.
|
|
114
|
+
*/
|
|
115
|
+
export function applyFleetCounterPricing(payload, actingAgentId) {
|
|
116
|
+
if (payload.price != null && payload.price !== undefined) {
|
|
117
|
+
return payload;
|
|
118
|
+
}
|
|
119
|
+
const cents = resolveDefaultPriceCentsForExecutor(actingAgentId, payload.description ?? payload.agreementDescription);
|
|
120
|
+
if (cents == null)
|
|
121
|
+
return payload;
|
|
122
|
+
return { ...payload, price: cents };
|
|
123
|
+
}
|
|
124
|
+
/** User or agent direct-create / marketplace: default from provider specialist. */
|
|
125
|
+
export function resolveDefaultPriceForProvider(providerId, description, explicitPrice) {
|
|
126
|
+
if (typeof explicitPrice === 'number')
|
|
127
|
+
return explicitPrice;
|
|
128
|
+
return resolveDefaultPriceCentsForExecutor(providerId, description);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Infer fleet actor when tool context omits agentId (ZIG-368 safety net).
|
|
132
|
+
*/
|
|
133
|
+
export function inferFleetPricingActorId(payload) {
|
|
134
|
+
const executor = payload.executorId != null ? String(payload.executorId) : '';
|
|
135
|
+
if (executor && isFirstPartyFleetAgent(executor))
|
|
136
|
+
return executor;
|
|
137
|
+
const provider = payload.providerId != null ? String(payload.providerId) : '';
|
|
138
|
+
if (provider && isFirstPartyFleetAgent(provider))
|
|
139
|
+
return provider;
|
|
140
|
+
const proposed = payload.proposedTo != null ? String(payload.proposedTo) : '';
|
|
141
|
+
if (proposed && isFirstPartyFleetAgent(proposed))
|
|
142
|
+
return proposed;
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
/** Apply fleet defaults with optional acting agent (falls back to payload inference). */
|
|
146
|
+
export function applyFleetPricingForProtocol(operation, payload, actingAgentId) {
|
|
147
|
+
const actor = actingAgentId?.trim() || inferFleetPricingActorId(payload);
|
|
148
|
+
if (!actor) {
|
|
149
|
+
if (operation === 'agreement-propose') {
|
|
150
|
+
const specialist = (payload.providerId != null ? String(payload.providerId) : '') ||
|
|
151
|
+
(payload.proposedTo != null && isFirstPartyFleetAgent(String(payload.proposedTo))
|
|
152
|
+
? String(payload.proposedTo)
|
|
153
|
+
: '');
|
|
154
|
+
if (specialist) {
|
|
155
|
+
const cents = resolveDefaultPriceCentsForExecutor(specialist, payload.description ?? payload.agreementDescription);
|
|
156
|
+
if (cents != null)
|
|
157
|
+
return { ...payload, price: cents };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (operation === 'agreement-subcontract' && payload.executorId) {
|
|
161
|
+
const cents = resolveDefaultPriceCentsForExecutor(String(payload.executorId), payload.description);
|
|
162
|
+
if (cents != null)
|
|
163
|
+
return { ...payload, price: cents };
|
|
164
|
+
}
|
|
165
|
+
return payload;
|
|
166
|
+
}
|
|
167
|
+
return applyFleetAgreementPricing(operation, payload, actor);
|
|
168
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIG-395 — eval/harness free pricing via env flag (no SANDBOX id-shape regex).
|
|
3
|
+
*/
|
|
4
|
+
/** Capability-probe + test harness agents (agents/test/). */
|
|
5
|
+
export declare const EVAL_HARNESS_AGENT_IDS: Set<string>;
|
|
6
|
+
export declare function isEvalFreePricingEnabled(): boolean;
|
|
7
|
+
export declare function isEvalFreeExecutor(agentId: string): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIG-395 — eval/harness free pricing via env flag (no SANDBOX id-shape regex).
|
|
3
|
+
*/
|
|
4
|
+
/** Capability-probe + test harness agents (agents/test/). */
|
|
5
|
+
export const EVAL_HARNESS_AGENT_IDS = new Set([
|
|
6
|
+
'minimal-context-agent',
|
|
7
|
+
'forwarding-agent',
|
|
8
|
+
'failing-agent',
|
|
9
|
+
'messaging-only-agent',
|
|
10
|
+
'principal-agent',
|
|
11
|
+
'capability-probe-agent',
|
|
12
|
+
]);
|
|
13
|
+
export function isEvalFreePricingEnabled() {
|
|
14
|
+
return process.env.FLEET_EVAL_FREE_PRICING === 'true';
|
|
15
|
+
}
|
|
16
|
+
export function isEvalFreeExecutor(agentId) {
|
|
17
|
+
if (!isEvalFreePricingEnabled() || !agentId)
|
|
18
|
+
return false;
|
|
19
|
+
if (agentId === 'eval-user')
|
|
20
|
+
return true;
|
|
21
|
+
if (agentId.endsWith('--eval'))
|
|
22
|
+
return true;
|
|
23
|
+
return EVAL_HARNESS_AGENT_IDS.has(agentId);
|
|
24
|
+
}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* AUTO-GENERATED by scripts/build-fleet-tier-map.mjs — do not edit by hand.
|
|
3
3
|
* ZIG-368: Tier A trivial public lookups (free when price omitted).
|
|
4
4
|
*/
|
|
5
|
-
export const FREE_TIER_A_AGENT_IDS = new Set
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const FREE_TIER_A_AGENT_IDS = new Set([
|
|
6
|
+
"site-health-checker",
|
|
7
|
+
"timezone-expert",
|
|
8
|
+
"uv-index-advisor",
|
|
9
|
+
"weather-forecaster"
|
|
10
10
|
]);
|
|
11
|
-
|
|
12
11
|
export const FREE_TIER_A_COUNT = 4;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED by scripts/build-fleet-tier-map.mjs — do not edit by hand.
|
|
3
|
+
* ZIG-368: agent-sdk local default pricing (backend uses agent.pricingTier — ZIG-395).
|
|
4
|
+
*/
|
|
5
|
+
export type FleetPricingTier = 'A' | 'B' | 'C' | 'D';
|
|
6
|
+
export declare const FLEET_TIER_BY_AGENT_ID: Record<string, FleetPricingTier>;
|
|
7
|
+
export declare const FLEET_TIER_MAP_SIZE = 765;
|