@indexnetwork/protocol 4.5.0-rc.325.1 → 4.5.0-rc.326.1
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/agent/agent.tools.js +1 -1
- package/dist/agent/agent.tools.js.map +1 -1
- package/dist/agent/tests/fakes.d.ts +1 -1
- package/dist/agent/tests/fakes.d.ts.map +1 -1
- package/dist/agent/tests/fakes.js +2 -2
- package/dist/agent/tests/fakes.js.map +1 -1
- package/dist/negotiation/negotiation.graph.js +2 -2
- package/dist/negotiation/negotiation.graph.js.map +1 -1
- package/dist/opportunity/opportunity.graph.d.ts +1 -1
- package/dist/opportunity/opportunity.graph.js +8 -8
- package/dist/opportunity/opportunity.graph.js.map +1 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.d.ts +6 -5
- package/dist/shared/interfaces/agent-dispatcher.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.js.map +1 -1
- package/dist/shared/interfaces/agent.interface.d.ts +3 -2
- package/dist/shared/interfaces/agent.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/agent.interface.js.map +1 -1
- package/package.json +1 -1
|
@@ -37,11 +37,11 @@ export type AgentDispatchResult = {
|
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* Dispatches a negotiation turn to the appropriate agent.
|
|
40
|
-
* Tries
|
|
40
|
+
* Tries external (poller) agents first, falls back to system agent.
|
|
41
41
|
*/
|
|
42
42
|
export interface AgentDispatcher {
|
|
43
43
|
/**
|
|
44
|
-
* Attempt to dispatch a negotiation turn to
|
|
44
|
+
* Attempt to dispatch a negotiation turn to an external (poller) agent.
|
|
45
45
|
* @param userId - The user whose agent should handle this turn
|
|
46
46
|
* @param scope - Permission scope for agent resolution
|
|
47
47
|
* @param payload - Turn context (users, history, seed assessment)
|
|
@@ -56,10 +56,11 @@ export interface AgentDispatcher {
|
|
|
56
56
|
timeoutMs: number;
|
|
57
57
|
}): Promise<AgentDispatchResult>;
|
|
58
58
|
/**
|
|
59
|
-
* Check whether a user has an authorized
|
|
60
|
-
* Used at init to determine scenario-based turn caps.
|
|
59
|
+
* Check whether a user has an authorized external (poller) agent for the given
|
|
60
|
+
* scope. Used at init to determine scenario-based turn caps. Type-only by design
|
|
61
|
+
* (no heartbeat freshness) — see IND-410.
|
|
61
62
|
*/
|
|
62
|
-
|
|
63
|
+
hasExternalAgent(userId: string, scope: {
|
|
63
64
|
action: string;
|
|
64
65
|
scopeType: string;
|
|
65
66
|
scopeId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-dispatcher.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/agent-dispatcher.interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAEtH,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,EAAE,sBAAsB,CAAC;IAClC,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,EAAE,OAAO,CAAC;IACrB,iEAAiE;IACjE,YAAY,EAAE,OAAO,CAAC;IACtB,gHAAgH;IAChH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oCAAoC;AACpC,MAAM,MAAM,mBAAmB,GAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GACxC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAA;CAAE,GAClD;IAAE,OAAO,EAAE,KAAK,CAAC;IAA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S,CAAA;CAAE,GAClD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAC9D,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;OAIG;IACH,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7D,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-dispatcher.interface.js","sourceRoot":"/","sources":["shared/interfaces/agent-dispatcher.interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * AgentDispatcher interface for the negotiation graph.\n *\n * The graph calls dispatch() per turn and receives a result.\n * It never knows about webhooks, MCP, transports, or agent resolution.\n * The concrete implementation lives in the host application.\n */\n\nimport type { NegotiationTurn, UserNegotiationContext, SeedAssessment } from '../schemas/negotiation-state.schema.js';\n\n/** Payload sent to the dispatcher for each negotiation turn. */\nexport interface NegotiationTurnPayload {\n negotiationId: string;\n ownUser: UserNegotiationContext;\n otherUser: UserNegotiationContext;\n indexContext: { networkId: string; prompt?: string };\n seedAssessment: SeedAssessment;\n history: NegotiationTurn[];\n isFinalTurn: boolean;\n /** Whether ownUser is the party that initiated the discovery. */\n isDiscoverer: boolean;\n /** The explicit search query that triggered this discovery (if any). Takes priority over background intents. */\n discoveryQuery?: string;\n}\n\n/** Result of a dispatch attempt. */\nexport type AgentDispatchResult =\n | { handled: true; turn: NegotiationTurn }\n | { handled: false; reason: 'no_agent' | 'timeout' }\n | { handled: false; reason: 'waiting'; resumeToken: string };\n\n/**\n * Dispatches a negotiation turn to the appropriate agent.\n * Tries
|
|
1
|
+
{"version":3,"file":"agent-dispatcher.interface.js","sourceRoot":"/","sources":["shared/interfaces/agent-dispatcher.interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * AgentDispatcher interface for the negotiation graph.\n *\n * The graph calls dispatch() per turn and receives a result.\n * It never knows about webhooks, MCP, transports, or agent resolution.\n * The concrete implementation lives in the host application.\n */\n\nimport type { NegotiationTurn, UserNegotiationContext, SeedAssessment } from '../schemas/negotiation-state.schema.js';\n\n/** Payload sent to the dispatcher for each negotiation turn. */\nexport interface NegotiationTurnPayload {\n negotiationId: string;\n ownUser: UserNegotiationContext;\n otherUser: UserNegotiationContext;\n indexContext: { networkId: string; prompt?: string };\n seedAssessment: SeedAssessment;\n history: NegotiationTurn[];\n isFinalTurn: boolean;\n /** Whether ownUser is the party that initiated the discovery. */\n isDiscoverer: boolean;\n /** The explicit search query that triggered this discovery (if any). Takes priority over background intents. */\n discoveryQuery?: string;\n}\n\n/** Result of a dispatch attempt. */\nexport type AgentDispatchResult =\n | { handled: true; turn: NegotiationTurn }\n | { handled: false; reason: 'no_agent' | 'timeout' }\n | { handled: false; reason: 'waiting'; resumeToken: string };\n\n/**\n * Dispatches a negotiation turn to the appropriate agent.\n * Tries external (poller) agents first, falls back to system agent.\n */\nexport interface AgentDispatcher {\n /**\n * Attempt to dispatch a negotiation turn to an external (poller) agent.\n * @param userId - The user whose agent should handle this turn\n * @param scope - Permission scope for agent resolution\n * @param payload - Turn context (users, history, seed assessment)\n * @param options - Timeout configuration\n * @returns Handled result with turn, or unhandled result with reason\n */\n dispatch(\n userId: string,\n scope: { action: string; scopeType: string; scopeId?: string },\n payload: NegotiationTurnPayload,\n options: { timeoutMs: number },\n ): Promise<AgentDispatchResult>;\n\n /**\n * Check whether a user has an authorized external (poller) agent for the given\n * scope. Used at init to determine scenario-based turn caps. Type-only by design\n * (no heartbeat freshness) — see IND-410.\n */\n hasExternalAgent(\n userId: string,\n scope: { action: string; scopeType: string; scopeId?: string },\n ): Promise<boolean>;\n}\n"]}
|
|
@@ -7,7 +7,7 @@ export interface AgentRecord {
|
|
|
7
7
|
ownerId: string;
|
|
8
8
|
name: string;
|
|
9
9
|
description: string | null;
|
|
10
|
-
type: 'personal' | 'system';
|
|
10
|
+
type: 'personal' | 'external' | 'system';
|
|
11
11
|
status: 'active' | 'inactive';
|
|
12
12
|
metadata: Record<string, unknown>;
|
|
13
13
|
createdAt: Date;
|
|
@@ -39,7 +39,8 @@ export interface CreateAgentInput {
|
|
|
39
39
|
ownerId: string;
|
|
40
40
|
name: string;
|
|
41
41
|
description?: string;
|
|
42
|
-
|
|
42
|
+
/** Required: personal rows are auto-provisioned negotiators; tool/registration paths create 'external'. */
|
|
43
|
+
type: 'personal' | 'external' | 'system';
|
|
43
44
|
metadata?: Record<string, unknown>;
|
|
44
45
|
}
|
|
45
46
|
export interface CreateTransportInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MA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@
|
|
|
1
|
-
{"version":3,"file":"agent.interface.js","sourceRoot":"/","sources":["shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"agent.interface.js","sourceRoot":"/","sources":["shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6LH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB,EAAE,sCAAsC;IACxD,UAAU,EAAE,sCAAsC;CAC1C,CAAC","sourcesContent":["/**\n * Database adapter interface for agent registry operations.\n * Implemented by the host application and injected via ProtocolDeps.\n */\n\nexport interface AgentRecord {\n id: string;\n ownerId: string;\n name: string;\n description: string | null;\n type: 'personal' | 'external' | 'system';\n status: 'active' | 'inactive';\n metadata: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface AgentTransportRecord {\n id: string;\n agentId: string;\n channel: 'mcp';\n config: Record<string, unknown>;\n priority: number;\n active: boolean;\n failureCount: number;\n}\n\nexport interface AgentPermissionRecord {\n id: string;\n agentId: string;\n userId: string;\n scope: 'global' | 'node' | 'network';\n scopeId: string | null;\n actions: string[];\n createdAt: Date;\n}\n\nexport interface AgentWithRelations extends AgentRecord {\n transports: AgentTransportRecord[];\n permissions: AgentPermissionRecord[];\n}\n\nexport interface CreateAgentInput {\n ownerId: string;\n name: string;\n description?: string;\n /** Required: personal rows are auto-provisioned negotiators; tool/registration paths create 'external'. */\n type: 'personal' | 'external' | 'system';\n metadata?: Record<string, unknown>;\n}\n\nexport interface CreateTransportInput {\n agentId: string;\n channel: 'mcp';\n config?: Record<string, unknown>;\n priority?: number;\n}\n\nexport interface GrantPermissionInput {\n agentId: string;\n userId: string;\n scope?: 'global' | 'node' | 'network';\n scopeId?: string;\n actions: string[];\n}\n\n/**\n * Database adapter interface for agent registry operations.\n *\n * Handles CRUD for agents, their transports, and permission grants.\n * Implemented by the host application (backend) and injected into the\n * protocol layer via constructor injection at the composition root.\n */\nexport interface AgentDatabase {\n /**\n * Creates a new agent record.\n * @param input - Agent creation parameters.\n * @returns The persisted agent record.\n */\n createAgent(input: CreateAgentInput): Promise<AgentRecord>;\n\n /**\n * Retrieves an agent by its ID.\n * @param agentId - The agent UUID.\n * @returns The agent record, or null if not found.\n */\n getAgent(agentId: string): Promise<AgentRecord | null>;\n\n /**\n * Retrieves an agent along with its transports and permissions.\n * @param agentId - The agent UUID.\n * @returns The agent with relations, or null if not found.\n */\n getAgentWithRelations(agentId: string): Promise<AgentWithRelations | null>;\n\n /**\n * Updates mutable fields on an agent.\n * @param agentId - The agent UUID.\n * @param updates - Partial set of fields to update.\n * @returns The updated agent record, or null if not found.\n */\n updateAgent(\n agentId: string,\n updates: Partial<Pick<AgentRecord, 'name' | 'description' | 'status' | 'metadata'>>,\n ): Promise<AgentRecord | null>;\n\n /**\n * Deletes an agent and its associated transports and permissions.\n * @param agentId - The agent UUID.\n */\n deleteAgent(agentId: string): Promise<void>;\n\n /**\n * Lists all agents owned by a user, including their relations.\n * @param userId - The owner's user ID.\n * @returns Array of agents with transports and permissions.\n */\n listAgentsForUser(userId: string): Promise<AgentWithRelations[]>;\n\n /**\n * Creates a transport channel for an agent.\n * @param input - Transport creation parameters.\n * @returns The persisted transport record.\n */\n createTransport(input: CreateTransportInput): Promise<AgentTransportRecord>;\n\n /**\n * Deletes a transport channel.\n * @param transportId - The transport UUID.\n */\n deleteTransport(transportId: string): Promise<void>;\n\n /**\n * Increments the failure counter for a transport channel.\n * @param transportId - The transport UUID.\n */\n recordTransportFailure(transportId: string): Promise<void>;\n\n /**\n * Resets the failure counter for a transport channel after a successful delivery.\n * @param transportId - The transport UUID.\n */\n recordTransportSuccess(transportId: string): Promise<void>;\n\n /**\n * Grants a permission to an agent for a given user and scope.\n * @param input - Permission grant parameters.\n * @returns The persisted permission record.\n */\n grantPermission(input: GrantPermissionInput): Promise<AgentPermissionRecord>;\n\n /**\n * Revokes a permission by its ID.\n * @param permissionId - The permission UUID.\n */\n revokePermission(permissionId: string): Promise<void>;\n\n /**\n * Checks whether an agent holds a specific permission for a user.\n * @param agentId - The agent UUID.\n * @param userId - The user whose permission is being checked.\n * @param action - The action string to verify (e.g. `\"read\"`, `\"write\"`).\n * @param scope - Optional scope restriction; defaults to global if omitted.\n * @returns True if the permission exists, false otherwise.\n */\n hasPermission(\n agentId: string,\n userId: string,\n action: string,\n scope?: { type: 'global' | 'node' | 'network'; id?: string },\n ): Promise<boolean>;\n\n /**\n * Returns all agents authorized for a user and action, optionally within a scope.\n * @param userId - The user to check authorization for.\n * @param action - The action string (e.g. `\"read\"`, `\"write\"`).\n * @param scope - Optional scope restriction.\n * @returns Array of authorized agents with their relations.\n */\n findAuthorizedAgents(\n userId: string,\n action: string,\n scope?: { type: 'global' | 'node' | 'network'; id?: string },\n ): Promise<AgentWithRelations[]>;\n\n /**\n * Returns the well-known IDs for built-in system agents.\n * @returns Object mapping system agent roles to their fixed UUIDs.\n */\n getSystemAgentIds(): { chatOrchestrator: string; negotiator: string };\n}\n\n/**\n * Fixed UUIDs for built-in system agents.\n *\n * These are seeded into the database on first run and must never change,\n * as they are referenced by foreign keys and hard-coded in protocol logic.\n */\nexport const SYSTEM_AGENT_IDS = {\n chatOrchestrator: '00000000-0000-0000-0000-000000000001',\n negotiator: '00000000-0000-0000-0000-000000000002',\n} as const;\n"]}
|