@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.
- package/CHANGELOG.md +141 -0
- package/IMPLEMENTATION.md +50 -52
- package/STABILITY.md +3 -3
- package/dist/chat/chat.agent.js +2 -3
- package/dist/chat/chat.graph.d.ts +41 -1
- package/dist/chat/chat.graph.js +108 -127
- package/dist/chat/negotiator.persona.d.ts +1 -1
- package/dist/chat/negotiator.persona.js +1 -4
- package/dist/chat/negotiator.prompt.js +1 -2
- package/dist/chat/onboarding.persona.js +0 -1
- package/dist/chat/reporter.persona.js +0 -1
- package/dist/chat/signal.persona.js +0 -1
- package/dist/contacts/application/contact.tools.d.ts +6 -9
- package/dist/contacts/application/contact.tools.js +11 -92
- package/dist/contacts/application/index.d.ts +2 -14
- package/dist/contacts/application/index.js +2 -13
- package/dist/contacts/domain/contact.types.d.ts +0 -23
- package/dist/contacts/domain/index.d.ts +2 -6
- package/dist/contacts/index.d.ts +1 -1
- package/dist/contacts/index.js +1 -1
- package/dist/contacts/ports/contact.repository.port.d.ts +5 -12
- package/dist/contacts/ports/contact.repository.port.js +4 -6
- package/dist/contacts/ports/contact.tools.port.d.ts +1 -3
- package/dist/contacts/ports/contact.tools.port.js +1 -2
- package/dist/contacts/ports/index.d.ts +1 -1
- package/dist/contacts/ports/index.js +1 -1
- package/dist/discovery/hyde.frame.d.ts +4 -4
- package/dist/discovery/hyde.graph.d.ts +71 -12
- package/dist/discovery/hyde.graph.js +337 -335
- package/dist/discovery/lens.inferrer.d.ts +6 -6
- package/dist/enrichment/enrichment.graph.d.ts +127 -9
- package/dist/enrichment/enrichment.graph.js +633 -655
- package/dist/enrichment/enrichment.state.d.ts +1 -1
- package/dist/enrichment/enrichment.tools.context-read.d.ts +10 -0
- package/dist/enrichment/enrichment.tools.context-read.js +353 -0
- package/dist/enrichment/enrichment.tools.context-write.d.ts +9 -0
- package/dist/enrichment/enrichment.tools.context-write.js +417 -0
- package/dist/enrichment/enrichment.tools.d.ts +11 -1
- package/dist/enrichment/enrichment.tools.helpers.d.ts +139 -0
- package/dist/enrichment/enrichment.tools.helpers.js +234 -0
- package/dist/enrichment/enrichment.tools.js +16 -975
- package/dist/index.d.ts +27 -50
- package/dist/index.js +17 -28
- package/dist/intents/application/intent.graph.d.ts +71 -67
- package/dist/intents/application/intent.graph.execute.d.ts +59 -0
- package/dist/intents/application/intent.graph.execute.js +301 -0
- package/dist/intents/application/intent.graph.infer.d.ts +44 -0
- package/dist/intents/application/intent.graph.infer.js +97 -0
- package/dist/intents/application/intent.graph.js +96 -888
- package/dist/intents/application/intent.graph.reconcile.d.ts +71 -0
- package/dist/intents/application/intent.graph.reconcile.js +274 -0
- package/dist/intents/application/intent.graph.shared.d.ts +70 -0
- package/dist/intents/application/intent.graph.shared.js +153 -0
- package/dist/intents/domain/intent.state.d.ts +1 -1
- package/dist/maintenance/maintenance.graph.d.ts +66 -3
- package/dist/maintenance/maintenance.graph.js +155 -156
- package/dist/mcp/mcp.authorization-policy.d.ts +24 -28
- package/dist/mcp/mcp.authorization-policy.js +14 -34
- package/dist/mcp/mcp.server.d.ts +3 -3
- package/dist/mcp/mcp.server.js +14 -20
- package/dist/negotiations/application/negotiation.candidates.d.ts +83 -0
- package/dist/negotiations/application/negotiation.candidates.js +162 -0
- package/dist/negotiations/application/negotiation.graph.d.ts +91 -157
- package/dist/negotiations/application/negotiation.graph.finalize.d.ts +5 -0
- package/dist/negotiations/application/negotiation.graph.finalize.js +280 -0
- package/dist/negotiations/application/negotiation.graph.init.d.ts +54 -0
- package/dist/negotiations/application/negotiation.graph.init.js +227 -0
- package/dist/negotiations/application/negotiation.graph.js +69 -1388
- package/dist/negotiations/application/negotiation.graph.screen.d.ts +23 -0
- package/dist/negotiations/application/negotiation.graph.screen.js +108 -0
- package/dist/negotiations/application/negotiation.graph.shared.d.ts +75 -0
- package/dist/negotiations/application/negotiation.graph.shared.js +125 -0
- package/dist/negotiations/application/negotiation.graph.turn.d.ts +105 -0
- package/dist/negotiations/application/negotiation.graph.turn.js +484 -0
- package/dist/negotiations/domain/negotiation.state.d.ts +1 -1
- package/dist/negotiations/domain/negotiation.state.js +0 -1
- package/dist/networks/application/indexer.graph.d.ts +165 -7
- package/dist/networks/application/indexer.graph.js +339 -388
- package/dist/networks/application/indexer.state.d.ts +1 -1
- package/dist/networks/application/membership.graph.d.ts +83 -5
- package/dist/networks/application/membership.graph.js +177 -207
- package/dist/networks/application/network.graph.d.ts +148 -5
- package/dist/networks/application/network.graph.js +249 -278
- package/dist/networks/domain/membership.state.d.ts +1 -1
- package/dist/networks/domain/network.state.d.ts +1 -1
- package/dist/opportunities/application/delivery-card.cache.d.ts +1 -1
- package/dist/opportunities/application/delivery-card.cache.js +2 -2
- package/dist/opportunities/application/index.d.ts +2 -2
- package/dist/opportunities/application/index.js +2 -2
- package/dist/opportunities/application/opportunity.evaluator.js +1 -1
- package/dist/opportunities/application/opportunity.graph.d.ts +686 -473
- package/dist/opportunities/application/opportunity.graph.discovery-strategies.d.ts +109 -0
- package/dist/opportunities/application/opportunity.graph.discovery-strategies.js +451 -0
- package/dist/opportunities/application/opportunity.graph.discovery.d.ts +69 -0
- package/dist/opportunities/application/opportunity.graph.discovery.js +397 -0
- package/dist/opportunities/application/opportunity.graph.evaluation.d.ts +82 -0
- package/dist/opportunities/application/opportunity.graph.evaluation.js +608 -0
- package/dist/opportunities/application/opportunity.graph.js +120 -3690
- package/dist/opportunities/application/opportunity.graph.modes.d.ts +538 -0
- package/dist/opportunities/application/opportunity.graph.modes.js +538 -0
- package/dist/opportunities/application/opportunity.graph.negotiate.d.ts +109 -0
- package/dist/opportunities/application/opportunity.graph.negotiate.js +392 -0
- package/dist/opportunities/application/opportunity.graph.persist-node.d.ts +93 -0
- package/dist/opportunities/application/opportunity.graph.persist-node.js +765 -0
- package/dist/opportunities/application/opportunity.graph.prep.d.ts +150 -0
- package/dist/opportunities/application/opportunity.graph.prep.js +381 -0
- package/dist/opportunities/application/opportunity.graph.shared.d.ts +173 -0
- package/dist/opportunities/application/opportunity.graph.shared.js +199 -0
- package/dist/opportunities/application/opportunity.presentation.d.ts +399 -0
- package/dist/opportunities/application/{opportunity.presenter.js → opportunity.presentation.js} +735 -9
- package/dist/opportunities/application/opportunity.tools.cards.d.ts +152 -0
- package/dist/opportunities/application/opportunity.tools.cards.js +235 -0
- package/dist/opportunities/application/opportunity.tools.d.ts +8 -114
- package/dist/opportunities/application/opportunity.tools.js +28 -711
- package/dist/opportunities/application/opportunity.tools.list.d.ts +10 -0
- package/dist/opportunities/application/opportunity.tools.list.js +493 -0
- package/dist/opportunities/domain/index.d.ts +3 -3
- package/dist/opportunities/domain/index.js +3 -3
- package/dist/opportunities/domain/opportunity.state.d.ts +19 -19
- package/dist/opportunities/index.d.ts +6 -6
- package/dist/opportunities/index.js +4 -4
- package/dist/opportunities/ports/opportunity.tools.port.d.ts +1 -1
- package/dist/opportunities/radar/radar.graph.d.ts +57 -13
- package/dist/opportunities/radar/radar.graph.js +470 -471
- package/dist/premises/premise.graph.d.ts +88 -20
- package/dist/premises/premise.graph.js +207 -218
- package/dist/questions/domain/question.schema.d.ts +40 -40
- package/dist/shared/agent/tool.factory.js +0 -8
- package/dist/shared/agent/tool.helpers.d.ts +21 -45
- package/dist/shared/agent/tool.helpers.js +1 -2
- package/dist/shared/agent/tool.registry.d.ts +4 -3
- package/dist/shared/agent/tool.registry.js +2 -4
- package/dist/shared/agent/tool.runtime.js +0 -2
- package/dist/shared/agent/utility.tools.js +9 -13
- package/dist/shared/interfaces/database.capabilities.d.ts +100 -0
- package/dist/shared/interfaces/database.capabilities.js +7 -0
- package/dist/shared/interfaces/database.entities.d.ts +533 -0
- package/dist/shared/interfaces/database.entities.js +10 -0
- package/dist/shared/interfaces/database.identity-queries.d.ts +294 -0
- package/dist/shared/interfaces/database.identity-queries.js +4 -0
- package/dist/shared/interfaces/database.interface.d.ts +15 -2277
- package/dist/shared/interfaces/database.interface.js +8 -0
- package/dist/shared/interfaces/database.member-queries.d.ts +221 -0
- package/dist/shared/interfaces/database.member-queries.js +4 -0
- package/dist/shared/interfaces/database.negotiation.d.ts +305 -0
- package/dist/shared/interfaces/database.negotiation.js +26 -0
- package/dist/shared/interfaces/database.network-queries.d.ts +277 -0
- package/dist/shared/interfaces/database.network-queries.js +4 -0
- package/dist/shared/interfaces/database.opportunity-queries.d.ts +285 -0
- package/dist/shared/interfaces/database.opportunity-queries.js +4 -0
- package/dist/shared/interfaces/database.port.d.ts +322 -0
- package/dist/shared/interfaces/database.port.js +29 -0
- package/dist/shared/schemas/discovery-question.schema.d.ts +14 -14
- package/dist/shared/schemas/negotiation-digest.schema.d.ts +2 -2
- package/package.json +2 -15
- package/dist/contacts/application/contact.inviter.d.ts +0 -49
- package/dist/contacts/application/contact.inviter.js +0 -64
- package/dist/integrations/application/index.d.ts +0 -14
- package/dist/integrations/application/index.js +0 -14
- package/dist/integrations/application/integration.tools.d.ts +0 -27
- package/dist/integrations/application/integration.tools.js +0 -98
- package/dist/integrations/domain/index.d.ts +0 -16
- package/dist/integrations/domain/index.js +0 -1
- package/dist/integrations/domain/integration.types.d.ts +0 -51
- package/dist/integrations/domain/integration.types.js +0 -9
- package/dist/integrations/index.d.ts +0 -10
- package/dist/integrations/index.js +0 -8
- package/dist/integrations/ports/index.d.ts +0 -25
- package/dist/integrations/ports/index.js +0 -23
- package/dist/integrations/ports/integration.adapter.port.d.ts +0 -62
- package/dist/integrations/ports/integration.adapter.port.js +0 -15
- package/dist/integrations/ports/integration.importer.port.d.ts +0 -31
- package/dist/integrations/ports/integration.importer.port.js +0 -15
- package/dist/integrations/ports/integration.tools.port.d.ts +0 -25
- package/dist/integrations/ports/integration.tools.port.js +0 -18
- package/dist/opportunities/application/opportunity.card-presentation.d.ts +0 -44
- package/dist/opportunities/application/opportunity.card-presentation.js +0 -93
- package/dist/opportunities/application/opportunity.presenter.d.ts +0 -156
- package/dist/opportunities/domain/opportunity.presentation-cache.d.ts +0 -5
- package/dist/opportunities/domain/opportunity.presentation-cache.js +0 -11
- package/dist/opportunities/domain/opportunity.presentation.d.ts +0 -76
- package/dist/opportunities/domain/opportunity.presentation.js +0 -516
- package/dist/opportunities/domain/opportunity.safe-presentation.d.ts +0 -104
- 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
|
-
}
|