@indexnetwork/protocol 0.4.0-rc.12.1 → 0.4.0-rc.13.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.
Files changed (38) hide show
  1. package/dist/agent/agent.tools.d.ts +3 -0
  2. package/dist/agent/agent.tools.d.ts.map +1 -0
  3. package/dist/agent/agent.tools.js +330 -0
  4. package/dist/agent/agent.tools.js.map +1 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp/mcp.server.d.ts +1 -1
  10. package/dist/mcp/mcp.server.d.ts.map +1 -1
  11. package/dist/mcp/mcp.server.js +6 -3
  12. package/dist/mcp/mcp.server.js.map +1 -1
  13. package/dist/opportunity/opportunity.graph.d.ts +31 -0
  14. package/dist/opportunity/opportunity.graph.d.ts.map +1 -1
  15. package/dist/opportunity/opportunity.graph.js +45 -2
  16. package/dist/opportunity/opportunity.graph.js.map +1 -1
  17. package/dist/opportunity/opportunity.tools.d.ts.map +1 -1
  18. package/dist/opportunity/opportunity.tools.js +12 -4
  19. package/dist/opportunity/opportunity.tools.js.map +1 -1
  20. package/dist/profile/profile.tools.d.ts.map +1 -1
  21. package/dist/profile/profile.tools.js +12 -1
  22. package/dist/profile/profile.tools.js.map +1 -1
  23. package/dist/shared/agent/tool.factory.d.ts.map +1 -1
  24. package/dist/shared/agent/tool.factory.js +5 -0
  25. package/dist/shared/agent/tool.factory.js.map +1 -1
  26. package/dist/shared/agent/tool.helpers.d.ts +11 -0
  27. package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
  28. package/dist/shared/agent/tool.helpers.js.map +1 -1
  29. package/dist/shared/agent/tool.registry.d.ts.map +1 -1
  30. package/dist/shared/agent/tool.registry.js +2 -0
  31. package/dist/shared/agent/tool.registry.js.map +1 -1
  32. package/dist/shared/interfaces/agent.interface.d.ts +176 -0
  33. package/dist/shared/interfaces/agent.interface.d.ts.map +1 -0
  34. package/dist/shared/interfaces/agent.interface.js +15 -0
  35. package/dist/shared/interfaces/agent.interface.js.map +1 -0
  36. package/dist/shared/interfaces/auth.interface.d.ts +10 -3
  37. package/dist/shared/interfaces/auth.interface.d.ts.map +1 -1
  38. package/package.json +1 -1
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Database adapter interface for agent registry operations.
3
+ * Implemented by the host application and injected via ProtocolDeps.
4
+ */
5
+ export interface AgentRecord {
6
+ id: string;
7
+ ownerId: string;
8
+ name: string;
9
+ description: string | null;
10
+ type: 'personal' | 'system';
11
+ status: 'active' | 'inactive';
12
+ metadata: Record<string, unknown>;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ }
16
+ export interface AgentTransportRecord {
17
+ id: string;
18
+ agentId: string;
19
+ channel: 'webhook' | 'mcp';
20
+ config: Record<string, unknown>;
21
+ priority: number;
22
+ active: boolean;
23
+ failureCount: number;
24
+ }
25
+ export interface AgentPermissionRecord {
26
+ id: string;
27
+ agentId: string;
28
+ userId: string;
29
+ scope: 'global' | 'node' | 'network';
30
+ scopeId: string | null;
31
+ actions: string[];
32
+ createdAt: Date;
33
+ }
34
+ export interface AgentWithRelations extends AgentRecord {
35
+ transports: AgentTransportRecord[];
36
+ permissions: AgentPermissionRecord[];
37
+ }
38
+ export interface CreateAgentInput {
39
+ ownerId: string;
40
+ name: string;
41
+ description?: string;
42
+ type?: 'personal' | 'system';
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ export interface CreateTransportInput {
46
+ agentId: string;
47
+ channel: 'webhook' | 'mcp';
48
+ config?: Record<string, unknown>;
49
+ priority?: number;
50
+ }
51
+ export interface GrantPermissionInput {
52
+ agentId: string;
53
+ userId: string;
54
+ scope?: 'global' | 'node' | 'network';
55
+ scopeId?: string;
56
+ actions: string[];
57
+ }
58
+ /**
59
+ * Database adapter interface for agent registry operations.
60
+ *
61
+ * Handles CRUD for agents, their transports, and permission grants.
62
+ * Implemented by the host application (backend) and injected into the
63
+ * protocol layer via constructor injection at the composition root.
64
+ */
65
+ export interface AgentDatabase {
66
+ /**
67
+ * Creates a new agent record.
68
+ * @param input - Agent creation parameters.
69
+ * @returns The persisted agent record.
70
+ */
71
+ createAgent(input: CreateAgentInput): Promise<AgentRecord>;
72
+ /**
73
+ * Retrieves an agent by its ID.
74
+ * @param agentId - The agent UUID.
75
+ * @returns The agent record, or null if not found.
76
+ */
77
+ getAgent(agentId: string): Promise<AgentRecord | null>;
78
+ /**
79
+ * Retrieves an agent along with its transports and permissions.
80
+ * @param agentId - The agent UUID.
81
+ * @returns The agent with relations, or null if not found.
82
+ */
83
+ getAgentWithRelations(agentId: string): Promise<AgentWithRelations | null>;
84
+ /**
85
+ * Updates mutable fields on an agent.
86
+ * @param agentId - The agent UUID.
87
+ * @param updates - Partial set of fields to update.
88
+ * @returns The updated agent record, or null if not found.
89
+ */
90
+ updateAgent(agentId: string, updates: Partial<Pick<AgentRecord, 'name' | 'description' | 'status' | 'metadata'>>): Promise<AgentRecord | null>;
91
+ /**
92
+ * Deletes an agent and its associated transports and permissions.
93
+ * @param agentId - The agent UUID.
94
+ */
95
+ deleteAgent(agentId: string): Promise<void>;
96
+ /**
97
+ * Lists all agents owned by a user, including their relations.
98
+ * @param userId - The owner's user ID.
99
+ * @returns Array of agents with transports and permissions.
100
+ */
101
+ listAgentsForUser(userId: string): Promise<AgentWithRelations[]>;
102
+ /**
103
+ * Creates a transport channel for an agent.
104
+ * @param input - Transport creation parameters.
105
+ * @returns The persisted transport record.
106
+ */
107
+ createTransport(input: CreateTransportInput): Promise<AgentTransportRecord>;
108
+ /**
109
+ * Deletes a transport channel.
110
+ * @param transportId - The transport UUID.
111
+ */
112
+ deleteTransport(transportId: string): Promise<void>;
113
+ /**
114
+ * Increments the failure counter for a transport channel.
115
+ * @param transportId - The transport UUID.
116
+ */
117
+ recordTransportFailure(transportId: string): Promise<void>;
118
+ /**
119
+ * Resets the failure counter for a transport channel after a successful delivery.
120
+ * @param transportId - The transport UUID.
121
+ */
122
+ recordTransportSuccess(transportId: string): Promise<void>;
123
+ /**
124
+ * Grants a permission to an agent for a given user and scope.
125
+ * @param input - Permission grant parameters.
126
+ * @returns The persisted permission record.
127
+ */
128
+ grantPermission(input: GrantPermissionInput): Promise<AgentPermissionRecord>;
129
+ /**
130
+ * Revokes a permission by its ID.
131
+ * @param permissionId - The permission UUID.
132
+ */
133
+ revokePermission(permissionId: string): Promise<void>;
134
+ /**
135
+ * Checks whether an agent holds a specific permission for a user.
136
+ * @param agentId - The agent UUID.
137
+ * @param userId - The user whose permission is being checked.
138
+ * @param action - The action string to verify (e.g. `"read"`, `"write"`).
139
+ * @param scope - Optional scope restriction; defaults to global if omitted.
140
+ * @returns True if the permission exists, false otherwise.
141
+ */
142
+ hasPermission(agentId: string, userId: string, action: string, scope?: {
143
+ type: 'global' | 'node' | 'network';
144
+ id?: string;
145
+ }): Promise<boolean>;
146
+ /**
147
+ * Returns all agents authorized for a user and action, optionally within a scope.
148
+ * @param userId - The user to check authorization for.
149
+ * @param action - The action string (e.g. `"read"`, `"write"`).
150
+ * @param scope - Optional scope restriction.
151
+ * @returns Array of authorized agents with their relations.
152
+ */
153
+ findAuthorizedAgents(userId: string, action: string, scope?: {
154
+ type: 'global' | 'node' | 'network';
155
+ id?: string;
156
+ }): Promise<AgentWithRelations[]>;
157
+ /**
158
+ * Returns the well-known IDs for built-in system agents.
159
+ * @returns Object mapping system agent roles to their fixed UUIDs.
160
+ */
161
+ getSystemAgentIds(): {
162
+ chatOrchestrator: string;
163
+ negotiator: string;
164
+ };
165
+ }
166
+ /**
167
+ * Fixed UUIDs for built-in system agents.
168
+ *
169
+ * These are seeded into the database on first run and must never change,
170
+ * as they are referenced by foreign keys and hard-coded in protocol logic.
171
+ */
172
+ export declare const SYSTEM_AGENT_IDS: {
173
+ readonly chatOrchestrator: "00000000-0000-0000-0000-000000000001";
174
+ readonly negotiator: "00000000-0000-0000-0000-000000000002";
175
+ };
176
+ //# sourceMappingURL=agent.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.interface.d.ts","sourceRoot":"","sources":["../../../src/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;IAC5B,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,GAAG,KAAK,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IACrC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACnC,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,gBAAgB;IAC/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gB,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CACvE;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Database adapter interface for agent registry operations.
3
+ * Implemented by the host application and injected via ProtocolDeps.
4
+ */
5
+ /**
6
+ * Fixed UUIDs for built-in system agents.
7
+ *
8
+ * These are seeded into the database on first run and must never change,
9
+ * as they are referenced by foreign keys and hard-coded in protocol logic.
10
+ */
11
+ export const SYSTEM_AGENT_IDS = {
12
+ chatOrchestrator: '00000000-0000-0000-0000-000000000001',
13
+ negotiator: '00000000-0000-0000-0000-000000000002',
14
+ };
15
+ //# sourceMappingURL=agent.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.interface.js","sourceRoot":"","sources":["../../../src/shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4LH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB,EAAE,sCAAsC;IACxD,UAAU,EAAE,sCAAsC;CAC1C,CAAC"}
@@ -1,15 +1,22 @@
1
1
  /**
2
- * Resolves the authenticated user ID from an incoming request.
2
+ * Resolves the authenticated MCP identity from an incoming request.
3
3
  * Injected into the MCP server factory so the protocol layer
4
4
  * stays independent of any specific auth implementation.
5
5
  */
6
6
  export interface McpAuthResolver {
7
7
  /**
8
- * Extracts and validates the authenticated user's ID from the request.
8
+ * Extracts and validates the authenticated identity from the request.
9
9
  * @param request - The incoming HTTP request
10
- * @returns The authenticated user's UUID
10
+ * @returns The authenticated user's UUID and optional agent UUID
11
11
  * @throws Error if authentication fails (no token, invalid token, etc.)
12
12
  */
13
+ resolveIdentity(request: Request): Promise<{
14
+ userId: string;
15
+ agentId?: string;
16
+ }>;
17
+ /**
18
+ * @deprecated Use resolveIdentity instead.
19
+ */
13
20
  resolveUserId(request: Request): Promise<string>;
14
21
  }
15
22
  //# sourceMappingURL=auth.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.interface.d.ts","sourceRoot":"","sources":["../../../src/shared/interfaces/auth.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD"}
1
+ {"version":3,"file":"auth.interface.d.ts","sourceRoot":"","sources":["../../../src/shared/interfaces/auth.interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEjF;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "0.4.0-rc.12.1",
3
+ "version": "0.4.0-rc.13.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",