@indexnetwork/protocol 14.3.2-rc.477.1 → 17.0.0-rc.479.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 (184) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/IMPLEMENTATION.md +50 -52
  3. package/STABILITY.md +3 -3
  4. package/dist/chat/chat.agent.js +2 -3
  5. package/dist/chat/chat.graph.d.ts +41 -1
  6. package/dist/chat/chat.graph.js +108 -127
  7. package/dist/chat/negotiator.persona.d.ts +1 -1
  8. package/dist/chat/negotiator.persona.js +1 -4
  9. package/dist/chat/negotiator.prompt.js +1 -2
  10. package/dist/chat/onboarding.persona.js +0 -1
  11. package/dist/chat/reporter.persona.js +0 -1
  12. package/dist/chat/signal.persona.js +0 -1
  13. package/dist/contacts/application/contact.tools.d.ts +6 -9
  14. package/dist/contacts/application/contact.tools.js +11 -92
  15. package/dist/contacts/application/index.d.ts +2 -14
  16. package/dist/contacts/application/index.js +2 -13
  17. package/dist/contacts/domain/contact.types.d.ts +0 -23
  18. package/dist/contacts/domain/index.d.ts +2 -6
  19. package/dist/contacts/index.d.ts +1 -1
  20. package/dist/contacts/index.js +1 -1
  21. package/dist/contacts/ports/contact.repository.port.d.ts +5 -12
  22. package/dist/contacts/ports/contact.repository.port.js +4 -6
  23. package/dist/contacts/ports/contact.tools.port.d.ts +1 -3
  24. package/dist/contacts/ports/contact.tools.port.js +1 -2
  25. package/dist/contacts/ports/index.d.ts +1 -1
  26. package/dist/contacts/ports/index.js +1 -1
  27. package/dist/discovery/hyde.frame.d.ts +4 -4
  28. package/dist/discovery/hyde.graph.d.ts +71 -12
  29. package/dist/discovery/hyde.graph.js +337 -335
  30. package/dist/discovery/lens.inferrer.d.ts +6 -6
  31. package/dist/enrichment/enrichment.graph.d.ts +127 -9
  32. package/dist/enrichment/enrichment.graph.js +633 -655
  33. package/dist/enrichment/enrichment.state.d.ts +1 -1
  34. package/dist/enrichment/enrichment.tools.context-read.d.ts +10 -0
  35. package/dist/enrichment/enrichment.tools.context-read.js +353 -0
  36. package/dist/enrichment/enrichment.tools.context-write.d.ts +9 -0
  37. package/dist/enrichment/enrichment.tools.context-write.js +417 -0
  38. package/dist/enrichment/enrichment.tools.d.ts +11 -1
  39. package/dist/enrichment/enrichment.tools.helpers.d.ts +139 -0
  40. package/dist/enrichment/enrichment.tools.helpers.js +234 -0
  41. package/dist/enrichment/enrichment.tools.js +16 -975
  42. package/dist/index.d.ts +27 -50
  43. package/dist/index.js +17 -28
  44. package/dist/intents/application/intent.graph.d.ts +71 -67
  45. package/dist/intents/application/intent.graph.execute.d.ts +59 -0
  46. package/dist/intents/application/intent.graph.execute.js +301 -0
  47. package/dist/intents/application/intent.graph.infer.d.ts +44 -0
  48. package/dist/intents/application/intent.graph.infer.js +97 -0
  49. package/dist/intents/application/intent.graph.js +96 -888
  50. package/dist/intents/application/intent.graph.reconcile.d.ts +71 -0
  51. package/dist/intents/application/intent.graph.reconcile.js +274 -0
  52. package/dist/intents/application/intent.graph.shared.d.ts +70 -0
  53. package/dist/intents/application/intent.graph.shared.js +153 -0
  54. package/dist/intents/domain/intent.state.d.ts +1 -1
  55. package/dist/maintenance/maintenance.graph.d.ts +66 -3
  56. package/dist/maintenance/maintenance.graph.js +155 -156
  57. package/dist/mcp/mcp.authorization-policy.d.ts +24 -28
  58. package/dist/mcp/mcp.authorization-policy.js +14 -34
  59. package/dist/mcp/mcp.server.d.ts +3 -3
  60. package/dist/mcp/mcp.server.js +14 -20
  61. package/dist/negotiations/application/negotiation.candidates.d.ts +83 -0
  62. package/dist/negotiations/application/negotiation.candidates.js +162 -0
  63. package/dist/negotiations/application/negotiation.graph.d.ts +91 -157
  64. package/dist/negotiations/application/negotiation.graph.finalize.d.ts +5 -0
  65. package/dist/negotiations/application/negotiation.graph.finalize.js +280 -0
  66. package/dist/negotiations/application/negotiation.graph.init.d.ts +54 -0
  67. package/dist/negotiations/application/negotiation.graph.init.js +227 -0
  68. package/dist/negotiations/application/negotiation.graph.js +69 -1388
  69. package/dist/negotiations/application/negotiation.graph.screen.d.ts +23 -0
  70. package/dist/negotiations/application/negotiation.graph.screen.js +108 -0
  71. package/dist/negotiations/application/negotiation.graph.shared.d.ts +75 -0
  72. package/dist/negotiations/application/negotiation.graph.shared.js +125 -0
  73. package/dist/negotiations/application/negotiation.graph.turn.d.ts +105 -0
  74. package/dist/negotiations/application/negotiation.graph.turn.js +484 -0
  75. package/dist/negotiations/domain/negotiation.state.d.ts +1 -1
  76. package/dist/negotiations/domain/negotiation.state.js +0 -1
  77. package/dist/networks/application/indexer.graph.d.ts +165 -7
  78. package/dist/networks/application/indexer.graph.js +339 -388
  79. package/dist/networks/application/indexer.state.d.ts +1 -1
  80. package/dist/networks/application/membership.graph.d.ts +83 -5
  81. package/dist/networks/application/membership.graph.js +177 -207
  82. package/dist/networks/application/network.graph.d.ts +148 -5
  83. package/dist/networks/application/network.graph.js +249 -278
  84. package/dist/networks/domain/membership.state.d.ts +1 -1
  85. package/dist/networks/domain/network.state.d.ts +1 -1
  86. package/dist/opportunities/application/delivery-card.cache.d.ts +1 -1
  87. package/dist/opportunities/application/delivery-card.cache.js +2 -2
  88. package/dist/opportunities/application/index.d.ts +2 -2
  89. package/dist/opportunities/application/index.js +2 -2
  90. package/dist/opportunities/application/opportunity.evaluator.js +1 -1
  91. package/dist/opportunities/application/opportunity.graph.d.ts +686 -473
  92. package/dist/opportunities/application/opportunity.graph.discovery-strategies.d.ts +109 -0
  93. package/dist/opportunities/application/opportunity.graph.discovery-strategies.js +451 -0
  94. package/dist/opportunities/application/opportunity.graph.discovery.d.ts +69 -0
  95. package/dist/opportunities/application/opportunity.graph.discovery.js +397 -0
  96. package/dist/opportunities/application/opportunity.graph.evaluation.d.ts +82 -0
  97. package/dist/opportunities/application/opportunity.graph.evaluation.js +608 -0
  98. package/dist/opportunities/application/opportunity.graph.js +120 -3690
  99. package/dist/opportunities/application/opportunity.graph.modes.d.ts +538 -0
  100. package/dist/opportunities/application/opportunity.graph.modes.js +538 -0
  101. package/dist/opportunities/application/opportunity.graph.negotiate.d.ts +109 -0
  102. package/dist/opportunities/application/opportunity.graph.negotiate.js +392 -0
  103. package/dist/opportunities/application/opportunity.graph.persist-node.d.ts +93 -0
  104. package/dist/opportunities/application/opportunity.graph.persist-node.js +765 -0
  105. package/dist/opportunities/application/opportunity.graph.prep.d.ts +150 -0
  106. package/dist/opportunities/application/opportunity.graph.prep.js +381 -0
  107. package/dist/opportunities/application/opportunity.graph.shared.d.ts +173 -0
  108. package/dist/opportunities/application/opportunity.graph.shared.js +199 -0
  109. package/dist/opportunities/application/opportunity.presentation.d.ts +399 -0
  110. package/dist/opportunities/application/{opportunity.presenter.js → opportunity.presentation.js} +735 -9
  111. package/dist/opportunities/application/opportunity.tools.cards.d.ts +152 -0
  112. package/dist/opportunities/application/opportunity.tools.cards.js +235 -0
  113. package/dist/opportunities/application/opportunity.tools.d.ts +8 -114
  114. package/dist/opportunities/application/opportunity.tools.js +28 -711
  115. package/dist/opportunities/application/opportunity.tools.list.d.ts +10 -0
  116. package/dist/opportunities/application/opportunity.tools.list.js +493 -0
  117. package/dist/opportunities/domain/index.d.ts +3 -3
  118. package/dist/opportunities/domain/index.js +3 -3
  119. package/dist/opportunities/domain/opportunity.state.d.ts +19 -19
  120. package/dist/opportunities/index.d.ts +6 -6
  121. package/dist/opportunities/index.js +4 -4
  122. package/dist/opportunities/ports/opportunity.tools.port.d.ts +1 -1
  123. package/dist/opportunities/radar/radar.graph.d.ts +57 -13
  124. package/dist/opportunities/radar/radar.graph.js +470 -471
  125. package/dist/premises/premise.graph.d.ts +88 -20
  126. package/dist/premises/premise.graph.js +207 -218
  127. package/dist/questions/domain/question.schema.d.ts +40 -40
  128. package/dist/shared/agent/tool.factory.js +0 -8
  129. package/dist/shared/agent/tool.helpers.d.ts +21 -45
  130. package/dist/shared/agent/tool.helpers.js +1 -2
  131. package/dist/shared/agent/tool.registry.d.ts +4 -3
  132. package/dist/shared/agent/tool.registry.js +2 -4
  133. package/dist/shared/agent/tool.runtime.js +0 -2
  134. package/dist/shared/agent/utility.tools.js +9 -13
  135. package/dist/shared/interfaces/database.capabilities.d.ts +100 -0
  136. package/dist/shared/interfaces/database.capabilities.js +7 -0
  137. package/dist/shared/interfaces/database.entities.d.ts +533 -0
  138. package/dist/shared/interfaces/database.entities.js +10 -0
  139. package/dist/shared/interfaces/database.identity-queries.d.ts +294 -0
  140. package/dist/shared/interfaces/database.identity-queries.js +4 -0
  141. package/dist/shared/interfaces/database.interface.d.ts +15 -2277
  142. package/dist/shared/interfaces/database.interface.js +8 -0
  143. package/dist/shared/interfaces/database.member-queries.d.ts +221 -0
  144. package/dist/shared/interfaces/database.member-queries.js +4 -0
  145. package/dist/shared/interfaces/database.negotiation.d.ts +305 -0
  146. package/dist/shared/interfaces/database.negotiation.js +26 -0
  147. package/dist/shared/interfaces/database.network-queries.d.ts +277 -0
  148. package/dist/shared/interfaces/database.network-queries.js +4 -0
  149. package/dist/shared/interfaces/database.opportunity-queries.d.ts +285 -0
  150. package/dist/shared/interfaces/database.opportunity-queries.js +4 -0
  151. package/dist/shared/interfaces/database.port.d.ts +322 -0
  152. package/dist/shared/interfaces/database.port.js +29 -0
  153. package/dist/shared/schemas/discovery-question.schema.d.ts +14 -14
  154. package/dist/shared/schemas/negotiation-digest.schema.d.ts +2 -2
  155. package/package.json +2 -15
  156. package/dist/contacts/application/contact.inviter.d.ts +0 -49
  157. package/dist/contacts/application/contact.inviter.js +0 -64
  158. package/dist/integrations/application/index.d.ts +0 -14
  159. package/dist/integrations/application/index.js +0 -14
  160. package/dist/integrations/application/integration.tools.d.ts +0 -27
  161. package/dist/integrations/application/integration.tools.js +0 -98
  162. package/dist/integrations/domain/index.d.ts +0 -16
  163. package/dist/integrations/domain/index.js +0 -1
  164. package/dist/integrations/domain/integration.types.d.ts +0 -51
  165. package/dist/integrations/domain/integration.types.js +0 -9
  166. package/dist/integrations/index.d.ts +0 -10
  167. package/dist/integrations/index.js +0 -8
  168. package/dist/integrations/ports/index.d.ts +0 -25
  169. package/dist/integrations/ports/index.js +0 -23
  170. package/dist/integrations/ports/integration.adapter.port.d.ts +0 -62
  171. package/dist/integrations/ports/integration.adapter.port.js +0 -15
  172. package/dist/integrations/ports/integration.importer.port.d.ts +0 -31
  173. package/dist/integrations/ports/integration.importer.port.js +0 -15
  174. package/dist/integrations/ports/integration.tools.port.d.ts +0 -25
  175. package/dist/integrations/ports/integration.tools.port.js +0 -18
  176. package/dist/opportunities/application/opportunity.card-presentation.d.ts +0 -44
  177. package/dist/opportunities/application/opportunity.card-presentation.js +0 -93
  178. package/dist/opportunities/application/opportunity.presenter.d.ts +0 -156
  179. package/dist/opportunities/domain/opportunity.presentation-cache.d.ts +0 -5
  180. package/dist/opportunities/domain/opportunity.presentation-cache.js +0 -11
  181. package/dist/opportunities/domain/opportunity.presentation.d.ts +0 -76
  182. package/dist/opportunities/domain/opportunity.presentation.js +0 -516
  183. package/dist/opportunities/domain/opportunity.safe-presentation.d.ts +0 -104
  184. package/dist/opportunities/domain/opportunity.safe-presentation.js +0 -102
@@ -1,98 +0,0 @@
1
- /**
2
- * integrations/application — createIntegrationTools canonical implementation.
3
- *
4
- * Creates integration tools for the chat agent. Exposes `import_gmail_contacts`
5
- * which authenticates via the integration adapter, fetches all Gmail contacts
6
- * (paginated), and imports them as ghost users into the network.
7
- *
8
- * Feature gating: import_gmail_contacts creates ghost users, so it is gated
9
- * behind the CONTACTS_ENABLED flag (deps.contactsEnabled). When disabled,
10
- * the tool is not registered at all (defineTool registers as a side effect).
11
- *
12
- * IND-549: moved from integration/integration.tools.ts into the canonical
13
- * integrations/application layer.
14
- */
15
- import { z } from 'zod';
16
- import { success, error } from '../../shared/agent/tool.helpers.js';
17
- import { requestContext } from "../../shared/observability/request-context.js";
18
- import { protocolLogger } from '../../shared/observability/protocol.logger.js';
19
- const logger = protocolLogger('ChatTools:Integration');
20
- /**
21
- * Creates integration tools for the chat agent.
22
- *
23
- * Exposes `import_gmail_contacts` which authenticates via the integration adapter,
24
- * fetches all Gmail contacts (paginated), and imports them as ghost users into the network.
25
- *
26
- * @param defineTool - Tool definition helper injected by the tool registry.
27
- * @param deps - Shared tool dependencies including the integration adapter.
28
- * @returns An array of tool definitions to register with the chat agent.
29
- */
30
- export function createIntegrationTools(defineTool, deps) {
31
- const { integration, integrationImporter } = deps;
32
- // import_gmail_contacts creates ghost users, so it is gated behind the
33
- // CONTACTS_ENABLED flag (injected as deps.contactsEnabled). When disabled the
34
- // tool is not registered at all (defineTool registers as a side effect).
35
- if (deps.contactsEnabled !== true) {
36
- return [];
37
- }
38
- const import_gmail_contacts = defineTool({
39
- name: 'import_gmail_contacts',
40
- description: "Imports contacts from the user's connected Gmail/Google account into their personal network. " +
41
- "This is the preferred method for importing Google Contacts — handles OAuth authentication, pagination, and deduplication automatically.\n\n" +
42
- "**Authentication flow:** If Gmail is not yet connected, returns an `authUrl` the user must visit to grant access. " +
43
- "After they complete OAuth, call this tool again to perform the actual import.\n\n" +
44
- "**What happens on import:** All Gmail contacts with valid name+email are imported. " +
45
- "Contacts without existing platform accounts become ghost users (enriched with public profile data from LinkedIn, GitHub, etc.). " +
46
- "All imported contacts are added to the user's personal network for opportunity discovery.\n\n" +
47
- "**When to use:** When the user asks to import or sync their Gmail/Google contacts. No parameters needed.\n\n" +
48
- "**Returns:** Either `{ requiresAuth: true, authUrl }` (user needs to authenticate) or import statistics: " +
49
- "imported (total), newContacts (ghost users created), existingContacts (already in network), skipped (invalid entries).",
50
- querySchema: z.object({}),
51
- handler: async ({ context }) => {
52
- try {
53
- const session = await integration.createSession(context.userId);
54
- const toolkits = await session.toolkits();
55
- const gmailToolkit = toolkits.items.find(t => t.slug === 'gmail');
56
- const isConnected = !!gmailToolkit?.connection?.connectedAccount?.id;
57
- if (!isConnected) {
58
- logger.info('Gmail not connected, returning auth URL', { userId: context.userId });
59
- const originUrl = requestContext.getStore()?.originUrl;
60
- const callbackUrl = originUrl ? `${originUrl}/oauth/callback` : undefined;
61
- const authRequest = await session.authorize('gmail', callbackUrl ? { callbackUrl } : undefined);
62
- return success({
63
- requiresAuth: true,
64
- message: 'Please connect your Gmail account to import contacts.',
65
- authUrl: authRequest.redirectUrl,
66
- });
67
- }
68
- const importResult = await integrationImporter.importContacts(context.userId, 'gmail');
69
- logger.info('Gmail contacts imported', {
70
- userId: context.userId,
71
- imported: importResult.imported,
72
- skipped: importResult.skipped,
73
- newContacts: importResult.newContacts,
74
- existingContacts: importResult.existingContacts,
75
- });
76
- return success({
77
- message: importResult.newContacts > 0
78
- ? `Imported ${importResult.imported} contacts from Gmail. ${importResult.newContacts} new, ${importResult.existingContacts} already in your network.`
79
- : importResult.imported > 0
80
- ? `All ${importResult.imported} contacts from Gmail were already in your network. No new contacts added.`
81
- : 'No contacts with valid name and email found in your Gmail account.',
82
- imported: importResult.imported,
83
- newContacts: importResult.newContacts,
84
- existingContacts: importResult.existingContacts,
85
- skipped: importResult.skipped,
86
- });
87
- }
88
- catch (err) {
89
- logger.error('import_gmail_contacts failed', {
90
- userId: context.userId,
91
- err,
92
- });
93
- return error('Failed to import Gmail contacts. Please try again.');
94
- }
95
- },
96
- });
97
- return [import_gmail_contacts];
98
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * integrations/domain — pure integration entity value types.
3
- *
4
- * Contains IntegrationSession, IntegrationSessionOptions, ToolActionResponse,
5
- * and IntegrationConnection.
6
- *
7
- * ## What does NOT live here
8
- *
9
- * - IntegrationAdapter: platform adapter port — lives in integrations/ports.
10
- * - IntegrationImporter: bulk-import port — lives in integrations/ports.
11
- * - IntegrationToolDeps: tool host port — lives in integrations/ports.
12
- * - createIntegrationTools: application layer — lives in integrations/application.
13
- *
14
- * IND-549: canonical domain layer for the integrations capability.
15
- */
16
- export type { IntegrationSession, IntegrationSessionOptions, ToolActionResponse, IntegrationConnection, } from "./integration.types.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- /**
2
- * integrations/domain — pure integration entity value types.
3
- *
4
- * Contains session shapes, connection records, and tool action responses.
5
- * No application logic, no LLM calls, no cross-capability imports.
6
- *
7
- * IND-549: canonical domain layer for the integrations capability.
8
- */
9
- /**
10
- * Session for interacting with an external integration platform.
11
- * Provides access to tools, OAuth authorization, and toolkit discovery.
12
- */
13
- export interface IntegrationSession {
14
- tools(): Promise<unknown[]>;
15
- authorize(toolkit: string): Promise<{
16
- redirectUrl: string;
17
- waitForConnection(timeout?: number): Promise<unknown>;
18
- }>;
19
- toolkits(): Promise<{
20
- items: Array<{
21
- slug: string;
22
- name: string;
23
- connection?: {
24
- connectedAccount?: {
25
- id: string;
26
- };
27
- };
28
- }>;
29
- }>;
30
- }
31
- /** Options for creating an integration session. */
32
- export interface IntegrationSessionOptions {
33
- manageConnections?: boolean | {
34
- callbackUrl?: string;
35
- };
36
- /** Toolkit slug → auth config ID mapping to pin existing auth configs. */
37
- authConfigs?: Record<string, string>;
38
- }
39
- /** Response from executing a tool action on the integration platform. */
40
- export interface ToolActionResponse {
41
- successful: boolean;
42
- error?: string;
43
- data?: Record<string, unknown>;
44
- }
45
- /** A connected integration account for a user. */
46
- export interface IntegrationConnection {
47
- id: string;
48
- toolkit: string;
49
- status: string;
50
- createdAt: string;
51
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * integrations/domain — pure integration entity value types.
3
- *
4
- * Contains session shapes, connection records, and tool action responses.
5
- * No application logic, no LLM calls, no cross-capability imports.
6
- *
7
- * IND-549: canonical domain layer for the integrations capability.
8
- */
9
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * integrations — the capability's sole cross-capability surface.
3
- *
4
- * Anything outside this capability imports from here and nowhere else.
5
- * Supersedes the capabilities/*.facade.ts + integrations/public/ pair; the export
6
- * list is the union of the facades it replaces, so the contract is unchanged.
7
- */
8
- export { createIntegrationTools, } from "./application/index.js";
9
- export type { IntegrationConnection, IntegrationSession, IntegrationSessionOptions, ToolActionResponse, } from "./domain/index.js";
10
- export type { IntegrationAdapter, IntegrationToolDeps, } from "./ports/index.js";
@@ -1,8 +0,0 @@
1
- /**
2
- * integrations — the capability's sole cross-capability surface.
3
- *
4
- * Anything outside this capability imports from here and nowhere else.
5
- * Supersedes the capabilities/*.facade.ts + integrations/public/ pair; the export
6
- * list is the union of the facades it replaces, so the contract is unchanged.
7
- */
8
- export { createIntegrationTools, } from "./application/index.js";
@@ -1,25 +0,0 @@
1
- /**
2
- * integrations/ports — injected dependency contracts for the integrations capability.
3
- *
4
- * Re-exports the narrow port types that the integrations module declares as
5
- * explicit injected boundaries. Consumers import these to wire host
6
- * implementations without depending on the application layer.
7
- *
8
- * ## Port groups
9
- *
10
- * ### Platform adapter port
11
- * - IntegrationAdapter — session creation, tool execution, connection management,
12
- * OAuth auth URLs, and disconnection.
13
- *
14
- * ### Bulk import port
15
- * - IntegrationImporter — toolkit-to-contacts bulk import pipeline.
16
- * - IntegrationImportResult — aggregate import statistics.
17
- *
18
- * ### Tool host port
19
- * - IntegrationToolDeps — host capabilities for integration-backed tools.
20
- *
21
- * IND-549: canonical ports surface for the integrations capability.
22
- */
23
- export type { IntegrationAdapter } from "./integration.adapter.port.js";
24
- export type { IntegrationImporter, IntegrationImportResult } from "./integration.importer.port.js";
25
- export type { IntegrationToolDeps } from "./integration.tools.port.js";
@@ -1,23 +0,0 @@
1
- /**
2
- * integrations/ports — injected dependency contracts for the integrations capability.
3
- *
4
- * Re-exports the narrow port types that the integrations module declares as
5
- * explicit injected boundaries. Consumers import these to wire host
6
- * implementations without depending on the application layer.
7
- *
8
- * ## Port groups
9
- *
10
- * ### Platform adapter port
11
- * - IntegrationAdapter — session creation, tool execution, connection management,
12
- * OAuth auth URLs, and disconnection.
13
- *
14
- * ### Bulk import port
15
- * - IntegrationImporter — toolkit-to-contacts bulk import pipeline.
16
- * - IntegrationImportResult — aggregate import statistics.
17
- *
18
- * ### Tool host port
19
- * - IntegrationToolDeps — host capabilities for integration-backed tools.
20
- *
21
- * IND-549: canonical ports surface for the integrations capability.
22
- */
23
- export {};
@@ -1,62 +0,0 @@
1
- /**
2
- * integrations/ports — IntegrationAdapter platform adapter port.
3
- *
4
- * Injected boundary for external integration platform access (OAuth sessions,
5
- * tool execution, connection management). Implemented by the host application
6
- * and passed into the protocol layer at the composition root.
7
- *
8
- * Retains host-integration configuration/actions semantics: adapter provides
9
- * session creation, tool execution, connection listing, OAuth auth URLs, and
10
- * disconnection — all platform-agnostic operations.
11
- *
12
- * IND-549: extracted from shared/interfaces/integration.interface.ts into the
13
- * integrations capability's dedicated ports layer.
14
- */
15
- import type { IntegrationSession, IntegrationSessionOptions, ToolActionResponse, IntegrationConnection } from "../domain/index.js";
16
- /**
17
- * Adapter for external integration platforms (OAuth sessions, tool execution).
18
- *
19
- * @remarks
20
- * Implementations wrap a specific platform SDK (e.g. Composio) and expose
21
- * a platform-agnostic API for creating user sessions and executing tool actions.
22
- */
23
- export interface IntegrationAdapter {
24
- /**
25
- * Create an authenticated session for a user.
26
- * @param userId - User ID for the session
27
- * @param options - Session configuration (e.g. connection management)
28
- * @returns A session object for interacting with the platform
29
- */
30
- createSession(userId: string, options?: IntegrationSessionOptions): Promise<IntegrationSession>;
31
- /**
32
- * Execute a named tool action on behalf of a user.
33
- * @param slug - Tool action identifier (e.g. 'GMAIL_GET_CONTACTS')
34
- * @param userId - User to execute the action for
35
- * @param args - Arguments to pass to the tool action
36
- * @returns The tool execution response
37
- */
38
- executeToolAction(slug: string, userId: string, args: Record<string, unknown>): Promise<ToolActionResponse>;
39
- /**
40
- * List all connected accounts for a user.
41
- * @param userId - User to list connections for
42
- * @returns Array of connected integration accounts
43
- */
44
- listConnections(userId: string): Promise<IntegrationConnection[]>;
45
- /**
46
- * Get an OAuth authorization URL to connect a toolkit.
47
- * @param userId - User to authorize
48
- * @param toolkit - Toolkit slug (e.g. 'gmail')
49
- * @param callbackUrl - URL to redirect to after OAuth
50
- * @returns The redirect URL for OAuth
51
- */
52
- getAuthUrl(userId: string, toolkit: string, callbackUrl?: string): Promise<{
53
- redirectUrl: string;
54
- }>;
55
- /**
56
- * Disconnect (delete) a connected account.
57
- * @param connectedAccountId - The connected account ID to remove
58
- */
59
- disconnect(connectedAccountId: string): Promise<{
60
- success: boolean;
61
- }>;
62
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * integrations/ports — IntegrationAdapter platform adapter port.
3
- *
4
- * Injected boundary for external integration platform access (OAuth sessions,
5
- * tool execution, connection management). Implemented by the host application
6
- * and passed into the protocol layer at the composition root.
7
- *
8
- * Retains host-integration configuration/actions semantics: adapter provides
9
- * session creation, tool execution, connection listing, OAuth auth URLs, and
10
- * disconnection — all platform-agnostic operations.
11
- *
12
- * IND-549: extracted from shared/interfaces/integration.interface.ts into the
13
- * integrations capability's dedicated ports layer.
14
- */
15
- export {};
@@ -1,31 +0,0 @@
1
- /**
2
- * integrations/ports — IntegrationImporter bulk-import port.
3
- *
4
- * Narrow port for bulk contact import from integration toolkits (e.g. Gmail).
5
- * Implemented by the host application and injected at the composition root.
6
- *
7
- * Decoupled from IntegrationAdapter: the importer handles the full import
8
- * pipeline (fetching, deduplication, ghost creation) so tools only need to
9
- * invoke it by toolkit slug — they do not need raw toolkit access.
10
- *
11
- * IND-549: extracted from the inline `integrationImporter` type in
12
- * shared/agent/tool.helpers.ts into the integrations capability's dedicated
13
- * ports layer as a named interface.
14
- */
15
- /** Result of a bulk contact import from an integration toolkit. */
16
- export interface IntegrationImportResult {
17
- imported: number;
18
- skipped: number;
19
- newContacts: number;
20
- existingContacts: number;
21
- }
22
- /**
23
- * Bulk contact importer for integration toolkit sources.
24
- *
25
- * Implementors handle the full fetch→match→ghost-create pipeline.
26
- * The tool layer invokes importContacts with the userId and the
27
- * toolkit slug (e.g. 'gmail') and receives aggregate import statistics.
28
- */
29
- export interface IntegrationImporter {
30
- importContacts(userId: string, toolkit: string): Promise<IntegrationImportResult>;
31
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * integrations/ports — IntegrationImporter bulk-import port.
3
- *
4
- * Narrow port for bulk contact import from integration toolkits (e.g. Gmail).
5
- * Implemented by the host application and injected at the composition root.
6
- *
7
- * Decoupled from IntegrationAdapter: the importer handles the full import
8
- * pipeline (fetching, deduplication, ghost creation) so tools only need to
9
- * invoke it by toolkit slug — they do not need raw toolkit access.
10
- *
11
- * IND-549: extracted from the inline `integrationImporter` type in
12
- * shared/agent/tool.helpers.ts into the integrations capability's dedicated
13
- * ports layer as a named interface.
14
- */
15
- export {};
@@ -1,25 +0,0 @@
1
- /**
2
- * integrations/ports — IntegrationToolDeps tool host port.
3
- *
4
- * Narrow port type consumed by createIntegrationTools. The host provides an
5
- * IntegrationAdapter, an IntegrationImporter, and the contactsEnabled flag
6
- * that gates the import_gmail_contacts tool (which creates ghost users).
7
- *
8
- * NOTE: This type is intentionally defined inline rather than derived from
9
- * ToolRegistryCompositionDeps, keeping the capability port independent from
10
- * the all-capability composition contract.
11
- *
12
- * Its shape remains structurally equivalent to the matching
13
- * ToolRegistryCompositionDeps fields.
14
- *
15
- * IND-549: extracted from capabilities/integrations.tools.port.ts into the
16
- * integrations capability's dedicated ports layer.
17
- */
18
- import type { IntegrationAdapter } from "./integration.adapter.port.js";
19
- import type { IntegrationImporter } from "./integration.importer.port.js";
20
- /** Host capabilities consumed by integration-backed contact import tools. */
21
- export type IntegrationToolDeps = {
22
- integration: IntegrationAdapter;
23
- integrationImporter: IntegrationImporter;
24
- contactsEnabled?: boolean;
25
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * integrations/ports — IntegrationToolDeps tool host port.
3
- *
4
- * Narrow port type consumed by createIntegrationTools. The host provides an
5
- * IntegrationAdapter, an IntegrationImporter, and the contactsEnabled flag
6
- * that gates the import_gmail_contacts tool (which creates ghost users).
7
- *
8
- * NOTE: This type is intentionally defined inline rather than derived from
9
- * ToolRegistryCompositionDeps, keeping the capability port independent from
10
- * the all-capability composition contract.
11
- *
12
- * Its shape remains structurally equivalent to the matching
13
- * ToolRegistryCompositionDeps fields.
14
- *
15
- * IND-549: extracted from capabilities/integrations.tools.port.ts into the
16
- * integrations capability's dedicated ports layer.
17
- */
18
- export {};
@@ -1,44 +0,0 @@
1
- /**
2
- * Minimal shape consumed by buildOpportunityPresentation for prose rendering.
3
- * Card data objects in the codebase carry additional frontend-only fields;
4
- * only these are surfaced to MCP agents.
5
- */
6
- export type OpportunityCardLike = Record<string, unknown> & {
7
- opportunityId: string;
8
- userId?: string | undefined;
9
- name?: string | undefined;
10
- mainText?: string | undefined;
11
- digestSummary?: string | undefined;
12
- status?: string | undefined;
13
- feedCategory?: string | undefined;
14
- profileUrl?: string | undefined;
15
- /** Universal link that opens this opportunity's card (`/o/<id>`). */
16
- appUrl?: string | undefined;
17
- /** Deep-link to the A2A negotiation trace that produced this opportunity. */
18
- negotiationUrl?: string | undefined;
19
- score?: number | undefined;
20
- /** Digest-mode cooldown re-show — the user has seen this card before. */
21
- redelivery?: boolean | undefined;
22
- };
23
- /**
24
- * Format opportunity cards into the "opportunities" portion of a tool response.
25
- *
26
- * Web chat (`isMcp=false`): emits ```opportunity``` code fences with an
27
- * "include EXACTLY as-is" directive so the frontend card renderer can parse
28
- * and render interactive cards.
29
- *
30
- * MCP (`isMcp=true`): emits prose (name, reason, status, appUrl and profileUrl
31
- * when present, feedCategory when present) and includes `opportunityId` for
32
- * every card so the agent can act via the tools. The trailing instruction
33
- * reminds the agent to synthesize in natural language, to surface the `appUrl`
34
- * verbatim as the one link that opens the card, and to fabricate no other URL.
35
- * MCP clients have no card renderer, so code fences would surface as raw JSON
36
- * to end users.
37
- */
38
- export declare function buildOpportunityPresentation(inputCards: OpportunityCardLike[], opts: {
39
- isMcp: boolean;
40
- leadIn: string;
41
- label?: 'opportunity' | 'opportunities';
42
- /** Include hidden digest metadata markers so scheduled brief tooling can confirm delivery. */
43
- includeDigestMarkers?: boolean;
44
- }): string;
@@ -1,93 +0,0 @@
1
- import { stripUnsupportedOpportunityClaims } from '../../shared/utils/claim-safety.js';
2
- import { stripUuids } from '../domain/opportunity.presentation.js';
3
- const CODE_FENCE = String.fromCharCode(96, 96, 96);
4
- function sanitizeJsonForCodeFence(json) {
5
- return json.replace(/`/g, '\\u0060');
6
- }
7
- function sanitizeOpportunityCardProse(card) {
8
- const sanitized = { ...card };
9
- for (const key of ['mainText', 'digestSummary', 'headline', 'cta', 'mutualIntentsLabel']) {
10
- const value = card[key];
11
- if (typeof value === 'string') {
12
- sanitized[key] = stripUnsupportedOpportunityClaims(stripUuids(value)) || 'A suggested connection.';
13
- }
14
- }
15
- const narratorChip = card.narratorChip;
16
- if (narratorChip && typeof narratorChip === 'object' && !Array.isArray(narratorChip)) {
17
- const narrator = narratorChip;
18
- if (typeof narrator.text === 'string') {
19
- sanitized.narratorChip = {
20
- ...narrator,
21
- text: stripUnsupportedOpportunityClaims(stripUuids(narrator.text)) || 'A potential connection worth exploring.',
22
- };
23
- }
24
- }
25
- return sanitized;
26
- }
27
- /**
28
- * Format opportunity cards into the "opportunities" portion of a tool response.
29
- *
30
- * Web chat (`isMcp=false`): emits ```opportunity``` code fences with an
31
- * "include EXACTLY as-is" directive so the frontend card renderer can parse
32
- * and render interactive cards.
33
- *
34
- * MCP (`isMcp=true`): emits prose (name, reason, status, appUrl and profileUrl
35
- * when present, feedCategory when present) and includes `opportunityId` for
36
- * every card so the agent can act via the tools. The trailing instruction
37
- * reminds the agent to synthesize in natural language, to surface the `appUrl`
38
- * verbatim as the one link that opens the card, and to fabricate no other URL.
39
- * MCP clients have no card renderer, so code fences would surface as raw JSON
40
- * to end users.
41
- */
42
- export function buildOpportunityPresentation(inputCards, opts) {
43
- const cards = inputCards.map(sanitizeOpportunityCardProse);
44
- if (cards.length === 0)
45
- return opts.leadIn;
46
- if (opts.isMcp) {
47
- const prose = cards
48
- .map((card, i) => {
49
- const lines = [`${i + 1}. ${card.name ?? "Unknown"}`];
50
- if (opts.includeDigestMarkers) {
51
- const markerId = String(card.opportunityId).replace(/[\s>]/g, "");
52
- if (markerId)
53
- lines.push(` <!-- digest-opportunity:id=${markerId} -->`);
54
- }
55
- if (opts.includeDigestMarkers && card.digestSummary) {
56
- lines.push(` ${card.digestSummary}`);
57
- }
58
- else if (card.mainText) {
59
- lines.push(` ${card.mainText}`);
60
- }
61
- if (card.status)
62
- lines.push(` status: ${card.status}`);
63
- if (card.appUrl)
64
- lines.push(` appUrl: ${card.appUrl}`);
65
- if (card.profileUrl)
66
- lines.push(` profileUrl: ${card.profileUrl}`);
67
- if (opts.includeDigestMarkers && card.negotiationUrl)
68
- lines.push(` negotiationUrl: ${card.negotiationUrl}`);
69
- if (card.feedCategory)
70
- lines.push(` feedCategory: ${card.feedCategory}`);
71
- if (opts.includeDigestMarkers && card.score != null)
72
- lines.push(` confidence: ${Math.round(card.score * 100)}`);
73
- if (opts.includeDigestMarkers && card.redelivery)
74
- lines.push(` redelivery: true`);
75
- lines.push(` opportunityId: ${card.opportunityId}`);
76
- return lines.join("\n");
77
- })
78
- .join("\n\n");
79
- const idInstructions = `Use opportunityId values only when calling update_opportunity (send/accept/reject) or confirm_opportunity_delivery.`;
80
- return (`${opts.leadIn}\n\n${prose}\n\n` +
81
- `Summarize these for the user in natural prose — mention first names and a brief match reason per connection. ` +
82
- `For each card that has a profileUrl, link the person's name to it. Some cards may have no URL — render those as plain text and never fabricate URLs for them. ` +
83
- `For each card that has an appUrl, show that link so the user can open the opportunity: it opens the card in the Index app when installed, and an Index web page otherwise. Show only an appUrl a tool returned — never assemble one from an opportunityId. ` +
84
- `No link accepts on the user's behalf: accepting happens in the Index app (or via update_opportunity) — never invent an accept URL. ` +
85
- `Do NOT print raw JSON, field labels, or opportunityIds. ` +
86
- `${idInstructions}`);
87
- }
88
- const label = opts.label ?? (cards.length === 1 ? "opportunity" : "opportunities");
89
- const blocks = cards
90
- .map((card) => CODE_FENCE + "opportunity\n" + sanitizeJsonForCodeFence(JSON.stringify(card)) + "\n" + CODE_FENCE)
91
- .join("\n\n");
92
- return (`${opts.leadIn} IMPORTANT: Include the following ${CODE_FENCE}${label} code blocks EXACTLY as-is in your response (they render as interactive cards):\n\n${blocks}`);
93
- }