@indexnetwork/protocol 6.15.0-rc.407.1 → 8.0.2-rc.418.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 +309 -0
- package/IMPLEMENTATION.md +7 -4
- package/dist/capabilities/opportunities.facade.d.ts +4 -0
- package/dist/capabilities/opportunities.facade.js +4 -0
- package/dist/chat/chat-streaming.types.d.ts +4 -5
- package/dist/chat/chat.agent.d.ts +0 -19
- package/dist/chat/chat.agent.js +1 -70
- package/dist/chat/chat.persona.d.ts +0 -6
- package/dist/chat/chat.persona.js +0 -1
- package/dist/chat/chat.prompt.js +10 -10
- package/dist/chat/chat.prompt.modules.js +0 -104
- package/dist/chat/chat.tools.js +11 -7
- package/dist/chat/negotiator.persona.js +0 -1
- package/dist/chat/onboarding.persona.js +0 -1
- package/dist/chat/reporter.persona.d.ts +1 -1
- package/dist/chat/reporter.persona.js +1 -2
- package/dist/chat/reporter.prompt.js +5 -5
- package/dist/chat/signal.persona.js +0 -1
- package/dist/communities/application/network.tools.js +48 -27
- package/dist/contacts/application/contact.tools.js +9 -9
- package/dist/index.d.ts +9 -2
- package/dist/index.js +5 -0
- package/dist/maintenance/maintenance.graph.js +7 -0
- package/dist/mcp/mcp.authorization-policy.d.ts +250 -0
- package/dist/mcp/mcp.authorization-policy.js +522 -0
- package/dist/mcp/mcp.server.d.ts +6 -29
- package/dist/mcp/mcp.server.js +202 -228
- package/dist/negotiation/application/negotiation.agent.js +29 -5
- package/dist/negotiation/application/negotiation.graph.d.ts +2 -5
- package/dist/negotiation/application/negotiation.graph.js +53 -23
- package/dist/negotiation/domain/index.d.ts +3 -0
- package/dist/negotiation/domain/index.js +3 -0
- package/dist/negotiation/domain/negotiation.deadlock.d.ts +7 -1
- package/dist/negotiation/domain/negotiation.deadlock.js +48 -1
- package/dist/negotiation/domain/negotiation.stance.contracts.d.ts +85 -0
- package/dist/negotiation/domain/negotiation.stance.contracts.js +140 -0
- package/dist/negotiation/domain/negotiation.state.d.ts +2 -3
- package/dist/negotiation/domain/negotiation.state.js +2 -3
- package/dist/negotiation/public/index.d.ts +2 -0
- package/dist/negotiation/public/index.js +2 -0
- package/dist/opportunity/application/index.d.ts +0 -3
- package/dist/opportunity/application/index.js +0 -3
- package/dist/opportunity/application/opportunity.graph.d.ts +0 -43
- package/dist/opportunity/application/opportunity.graph.js +7 -113
- package/dist/opportunity/application/opportunity.introducer-feature.d.ts +2 -0
- package/dist/opportunity/application/opportunity.introducer-feature.js +4 -0
- package/dist/opportunity/application/opportunity.owner-approval.d.ts +118 -0
- package/dist/opportunity/application/opportunity.owner-approval.js +34 -0
- package/dist/opportunity/application/opportunity.owner-provenance.d.ts +6 -0
- package/dist/opportunity/application/opportunity.owner-provenance.js +28 -0
- package/dist/opportunity/application/opportunity.tools.d.ts +3 -3
- package/dist/opportunity/application/opportunity.tools.js +77 -870
- package/dist/opportunity/discriminator/discriminator.shadow.js +17 -10
- package/dist/opportunity/discriminator/discriminator.types.d.ts +2 -0
- package/dist/opportunity/domain/index.d.ts +0 -2
- package/dist/opportunity/domain/index.js +0 -2
- package/dist/opportunity/domain/opportunity.state.d.ts +2 -70
- package/dist/opportunity/domain/opportunity.state.js +2 -55
- package/dist/opportunity/opportunity.owner-approval.d.ts +5 -0
- package/dist/opportunity/opportunity.owner-approval.js +5 -0
- package/dist/opportunity/ports/opportunity.tools.port.d.ts +12 -1
- package/dist/opportunity/public/index.d.ts +3 -3
- package/dist/opportunity/public/index.js +2 -1
- package/dist/participant-agents/application/agent.tools.d.ts +1 -1
- package/dist/participant-agents/application/agent.tools.js +44 -6
- package/dist/participant-agents/application/index.d.ts +5 -3
- package/dist/participant-agents/application/index.js +5 -3
- package/dist/questions/application/question.tools.js +31 -2
- package/dist/runtime/foreground/composition/tool.factory.d.ts +2 -1
- package/dist/runtime/foreground/composition/tool.factory.js +9 -2
- package/dist/runtime/foreground/composition/tool.registry.d.ts +16 -2
- package/dist/runtime/foreground/composition/tool.registry.js +41 -38
- package/dist/shared/agent/activity-projection.d.ts +271 -0
- package/dist/shared/agent/activity-projection.js +248 -0
- package/dist/shared/agent/canonical-guidance.d.ts +30 -0
- package/dist/shared/agent/canonical-guidance.js +249 -0
- package/dist/shared/agent/tool.helpers.d.ts +9 -17
- package/dist/shared/agent/tool.runtime.js +1 -3
- package/dist/shared/agent/utility.tools.d.ts +11 -1
- package/dist/shared/agent/utility.tools.js +126 -90
- package/dist/shared/interfaces/auth.interface.d.ts +2 -8
- package/dist/shared/interfaces/chat-session.interface.js +5 -0
- package/dist/shared/interfaces/database.interface.d.ts +12 -5
- package/dist/shared/observability/request-context.d.ts +4 -40
- package/dist/shared/schemas/mcp-auth.schema.d.ts +87 -15
- package/dist/shared/schemas/mcp-auth.schema.js +49 -1
- package/dist/signals/application/intent.tools.js +7 -8
- package/package.json +10 -9
- package/dist/opportunity/application/opportunity.discover.d.ts +0 -215
- package/dist/opportunity/application/opportunity.discover.js +0 -793
- package/dist/opportunity/application/opportunity.discovery-continuation-finalization.d.ts +0 -34
- package/dist/opportunity/application/opportunity.discovery-continuation-finalization.js +0 -74
- package/dist/opportunity/application/opportunity.discovery-mcp-lifecycle-finalization.d.ts +0 -44
- package/dist/opportunity/application/opportunity.discovery-mcp-lifecycle-finalization.js +0 -92
- package/dist/opportunity/domain/opportunity.discovery-run-coalescing.d.ts +0 -33
- package/dist/opportunity/domain/opportunity.discovery-run-coalescing.js +0 -33
- package/dist/opportunity/domain/opportunity.discovery.contracts.d.ts +0 -45
- package/dist/opportunity/domain/opportunity.discovery.contracts.js +0 -1
- package/dist/opportunity/opportunity.discover.d.ts +0 -5
- package/dist/opportunity/opportunity.discover.js +0 -5
- package/dist/opportunity/opportunity.discovery-continuation-finalization.d.ts +0 -5
- package/dist/opportunity/opportunity.discovery-continuation-finalization.js +0 -5
- package/dist/opportunity/opportunity.discovery-mcp-lifecycle-finalization.d.ts +0 -5
- package/dist/opportunity/opportunity.discovery-mcp-lifecycle-finalization.js +0 -5
- package/dist/opportunity/opportunity.discovery-run-coalescing.d.ts +0 -5
- package/dist/opportunity/opportunity.discovery-run-coalescing.js +0 -5
- package/dist/opportunity/opportunity.discovery.contracts.d.ts +0 -5
- package/dist/opportunity/opportunity.discovery.contracts.js +0 -5
- package/dist/shared/interfaces/discovery-run.interface.d.ts +0 -70
- package/dist/shared/interfaces/discovery-run.interface.js +0 -1
|
@@ -30,7 +30,7 @@ export function createContactTools(defineTool, deps) {
|
|
|
30
30
|
const import_contacts = contactsEnabled ? defineTool({
|
|
31
31
|
name: 'import_contacts',
|
|
32
32
|
description: "Bulk-imports contacts into the authenticated user's personal network (personal network). Contacts become members of the user's " +
|
|
33
|
-
"personal network with 'contact' permission, making
|
|
33
|
+
"personal network with 'contact' permission, making their approved signals eligible for background matching.\n\n" +
|
|
34
34
|
"**What happens:** Each contact is matched by email. If the email belongs to an existing user, they're linked directly. " +
|
|
35
35
|
"If not, a 'ghost user' is created — a placeholder account enriched with public profile data (from LinkedIn, GitHub, etc.) " +
|
|
36
36
|
"that participates in opportunity matching even before the person joins the platform.\n\n" +
|
|
@@ -67,9 +67,9 @@ export function createContactTools(defineTool, deps) {
|
|
|
67
67
|
"(via import_contacts, add_contact, or import_gmail_contacts) stored as members of their personal network.\n\n" +
|
|
68
68
|
"**When to use:** To see who's in the user's network, find a contact's userId for other operations, " +
|
|
69
69
|
"or check if a specific person is already a contact.\n\n" +
|
|
70
|
-
"**Returns:** Array of contacts, each with
|
|
71
|
-
"
|
|
72
|
-
"
|
|
70
|
+
"**Returns:** Array of contacts, each with userId (use with read_user_contexts), name, email, avatar URL, and isGhost " +
|
|
71
|
+
"(true = no account yet, profile enriched from public data). Use read_user_contexts(userId) to get the full profile. " +
|
|
72
|
+
"Approved signals are matched in the background; list_opportunities only reviews persisted results.",
|
|
73
73
|
querySchema: z.object({
|
|
74
74
|
limit: z.number().optional().describe('Maximum number of contacts to return. Omit to return all contacts. Use for large networks to paginate results.'),
|
|
75
75
|
}),
|
|
@@ -102,10 +102,10 @@ export function createContactTools(defineTool, deps) {
|
|
|
102
102
|
"For bulk imports, use import_contacts instead.\n\n" +
|
|
103
103
|
"**What happens:** Looks up the email. If an account exists, links that user as a contact. " +
|
|
104
104
|
"If not, creates a ghost user (placeholder enriched with public profile data) and adds them. " +
|
|
105
|
-
"
|
|
105
|
+
"Their approved signals can then become eligible for background matching within the user's personal network.\n\n" +
|
|
106
106
|
"**When to use:** When the user wants to add a specific person (e.g. 'add john@example.com to my network').\n\n" +
|
|
107
107
|
"**Returns:** Confirmation with the contact's userId and whether a new ghost user was created (isNewGhost). " +
|
|
108
|
-
"
|
|
108
|
+
"Background matching may create persisted opportunities from approved signals; list_opportunities only reviews those results.",
|
|
109
109
|
querySchema: z.object({
|
|
110
110
|
email: z.string().describe('Email address of the person to add. Used as unique identifier — if already a contact, the operation is idempotent.'),
|
|
111
111
|
name: z.string().optional().describe('Full name of the contact. Optional — if omitted, the email prefix is used as name. Provide when known for better profile enrichment.'),
|
|
@@ -131,10 +131,10 @@ export function createContactTools(defineTool, deps) {
|
|
|
131
131
|
const remove_contact = defineTool({
|
|
132
132
|
name: 'remove_contact',
|
|
133
133
|
description: "Removes a contact from the authenticated user's personal network. The contact relationship is deleted — " +
|
|
134
|
-
"the person is no longer a member of the user's personal network and
|
|
134
|
+
"the person is no longer a member of the user's personal network and their signals are no longer eligible for matching there.\n\n" +
|
|
135
135
|
"**When to use:** When the user wants to remove someone from their network (e.g. 'remove John from my contacts').\n\n" +
|
|
136
136
|
"**Note:** This only removes the contact relationship. If the contact is a real user (not a ghost), " +
|
|
137
|
-
"they still exist on the platform and may
|
|
137
|
+
"they still exist on the platform and their approved signals may remain eligible in shared networks.\n\n" +
|
|
138
138
|
"**Returns:** Confirmation that the contact was removed.",
|
|
139
139
|
querySchema: z.object({
|
|
140
140
|
contactUserId: z.string().describe('The userId of the contact to remove. Get this from list_contacts results.'),
|
|
@@ -154,7 +154,7 @@ export function createContactTools(defineTool, deps) {
|
|
|
154
154
|
name: 'search_contacts',
|
|
155
155
|
description: "Searches the authenticated user's personal network by name or email (case-insensitive substring). " +
|
|
156
156
|
"Use when the user refers to a contact by partial name or email and you need their userId for another tool " +
|
|
157
|
-
"(e.g. read_user_contexts
|
|
157
|
+
"(e.g. read_user_contexts).\n\n" +
|
|
158
158
|
"**When to use:** Before list_contacts when the network is large — returns only matching contacts, bounded by limit.\n\n" +
|
|
159
159
|
"**Returns:** Array of matching contacts: userId, name, email, avatar, isGhost.",
|
|
160
160
|
querySchema: z.object({
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export type { Embedder, VectorStoreOption, VectorSearchResult, HydeCandidate, Hy
|
|
|
21
21
|
export type { IntegrationAdapter, IntegrationConnection, IntegrationSession, IntegrationSessionOptions, ToolActionResponse } from "./shared/interfaces/integration.interface.js";
|
|
22
22
|
export type { IntentGraphQueue } from "./shared/interfaces/queue.interface.js";
|
|
23
23
|
export type { Scraper } from "./shared/interfaces/scraper.interface.js";
|
|
24
|
-
export type { DiscoveryRunInput, DiscoveryRunRecord } from "./shared/interfaces/discovery-run.interface.js";
|
|
25
24
|
export type { EnrichmentRunInput, EnrichmentRunRecord } from "./shared/interfaces/enrichment-run.interface.js";
|
|
26
25
|
export type { NegotiationTimeoutQueue, AskUserExpiryPayload } from "./shared/interfaces/negotiation-events.interface.js";
|
|
27
26
|
export type { AgentDispatcher, AgentDispatchResult, NegotiationTurnPayload } from "./shared/interfaces/agent-dispatcher.interface.js";
|
|
@@ -29,7 +28,8 @@ export { SYSTEM_AGENT_IDS } from './shared/interfaces/agent.interface.js';
|
|
|
29
28
|
export { ChatContextDigestSchema, type ChatContextDigest } from "./shared/schemas/chat-context.schema.js";
|
|
30
29
|
export { type Question, type UnderspecificationType, type QuestionStrategy, type QuestionGenerationResult, type QuestionPurpose, type NegotiationQuestionPurpose, type NegotiationQuestionCandidate, type NegotiationQuestionProvenance, NegotiationQuestionCandidateSchema, NegotiationQuestionProvenanceSchema, type QuestionPoolPush, type QuestionRecoverySnapshot, type QuestionVoidedReason, type QuestionPoolPushRequestStatus, type QuestionPoolPushRequestReason, } from "./shared/schemas/question.schema.js";
|
|
31
30
|
export type { PendingQuestionSummary } from "./shared/schemas/pending-question.schema.js";
|
|
32
|
-
export
|
|
31
|
+
export { McpAuthInputSchema, McpApiKeyMetadataSchema, McpResolvedIdentitySchema, } from "./shared/schemas/mcp-auth.schema.js";
|
|
32
|
+
export type { McpAuthInput, McpApiKeyMetadata, McpResolvedIdentity, } from "./shared/schemas/mcp-auth.schema.js";
|
|
33
33
|
export type { DiscoverySummary, DiscoveryNegotiation, DiscoveryTurn, DiscoveryOutcome, DiscoveryQuestionInput, NegotiationRole } from "./shared/schemas/discovery-question.schema.js";
|
|
34
34
|
export type { NetworkAssignmentMetadata } from "./shared/schemas/network-assignment.schema.js";
|
|
35
35
|
export { DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD, resolveAssignmentNetworkScope, buildNetworkAssignmentDecision } from "./shared/assignment/network-assignment.policy.js";
|
|
@@ -53,6 +53,8 @@ export { NegotiationGraphFactory, negotiateCandidates } from "./capabilities/neg
|
|
|
53
53
|
export { OpportunityGraphFactory } from "./capabilities/opportunities.facade.js";
|
|
54
54
|
export { hasUnsupportedOpportunityClaim } from "./capabilities/opportunities.facade.js";
|
|
55
55
|
export type { StampNewbornOpportunitiesFn } from "./capabilities/opportunities.facade.js";
|
|
56
|
+
export { opportunityOwnerActionForStatus, bindOwnerApprovalProvenance } from "./capabilities/opportunities.facade.js";
|
|
57
|
+
export type { OpportunityOwnerAction, OpportunityOwnerApprovalAttestation, OpportunityOwnerApprovalAuthority, OpportunityOwnerApprovalBinding, OpportunityOwnerApprovalChallenge, OpportunityOwnerApprovalDenialReason, OpportunityOwnerApprovalVerdict, OpportunityOwnerInteractionProvenance, OpportunityOwnerInteractionSurface, } from "./capabilities/opportunities.facade.js";
|
|
56
58
|
export { EnrichmentGraphFactory } from "./capabilities/participant-context.facade.js";
|
|
57
59
|
export { PremiseGraphFactory } from "./capabilities/participant-context.facade.js";
|
|
58
60
|
export { UserContextGenerator } from "./capabilities/participant-context.facade.js";
|
|
@@ -104,6 +106,7 @@ export { canUserSeeOpportunity, isActionableForViewer, validateOpportunityActors
|
|
|
104
106
|
export { getPrimaryActionLabel } from "./capabilities/opportunities.facade.js";
|
|
105
107
|
export { computeFeedHealth } from "./capabilities/opportunities.facade.js";
|
|
106
108
|
export type { FeedHealthInput } from "./capabilities/opportunities.facade.js";
|
|
109
|
+
export { isIntroducerDiscoveryEnabled } from "./capabilities/opportunities.facade.js";
|
|
107
110
|
export { selectContactsForDiscovery, shouldRunIntroducerDiscovery, runIntroducerDiscovery, MAX_CONTACTS_PER_CYCLE, MAX_CANDIDATES_PER_CONTACT, INTRODUCER_DISCOVERY_SOURCE } from "./capabilities/opportunities.facade.js";
|
|
108
111
|
export type { IntroducerDiscoveryDatabase, IntroducerDiscoveryQueue, ContactWithIntents } from "./capabilities/opportunities.facade.js";
|
|
109
112
|
export { persistOpportunities } from "./capabilities/opportunities.facade.js";
|
|
@@ -137,6 +140,10 @@ export { AMBIENT_PARK_WINDOW_MS } from './capabilities/negotiation.facade.js';
|
|
|
137
140
|
export { normalizeTelegramHandle } from './shared/utils/telegram-handle.js';
|
|
138
141
|
export { createMcpServer, buildMcpOnboardingMessage, ONBOARDING_ALLOWED } from "./mcp/mcp.server.js";
|
|
139
142
|
export type { ScopedDepsFactory } from "./mcp/mcp.server.js";
|
|
143
|
+
export { MCP_AGENT_ADMIN_TOOLS, CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS, CANONICAL_MCP_TOOL_ACCESS_RULES, MCP_INFORMATIONAL_TOOLS, MCP_PERMISSION_ACTIONS, McpCapabilityPolicy, McpCapabilitySubjectSchema, McpPermissionActionSchema, McpPolicyAgentSnapshotSchema, McpPrincipalProfileSchema, McpToolPermissionRequirementSchema, McpToolAccessRuleSchema, buildMcpAuthorizationDenialEvent, defineMcpToolAccessRules, defineMcpToolPermissionMap, resolveMcpActivityCaller, resolveMcpCapabilitySubject, } from "./mcp/mcp.authorization-policy.js";
|
|
144
|
+
export { ActivityQuestionCountsSchema, ActivityQuestionDomainSchema, ActivitySummaryDomainSchema, ActivitySummaryResponseSchema, McpActivityCallerSchema, QUESTION_MODE_TO_DOMAIN, READ_ACTIVITY_SUMMARY_TOOL_NAME, activitySummaryNetworkId, projectActivitySummary, resolveActivitySummaryDomains, } from "./shared/agent/activity-projection.js";
|
|
145
|
+
export type { ActivityQuestionCounts, ActivityQuestionDomain, ActivitySummaryDomain, McpActivityCaller, ProjectedActivitySummary, } from "./shared/agent/activity-projection.js";
|
|
146
|
+
export type { McpAuthorizationDenialEvent, McpAuthorizationObserver, McpCapabilityDecision, McpCapabilityDecisionReason, McpCapabilityPolicyOptions, McpCapabilitySubject, McpPermissionAction, McpPolicyAgentSnapshot, McpPrincipalProfile, McpToolPermissionMap, McpToolPermissionRequirement, McpToolAccessRule, McpToolAccessRuleMap, ResolveMcpCapabilitySubjectInput, } from "./mcp/mcp.authorization-policy.js";
|
|
140
147
|
export type { UserNegotiationContext, NegotiationTurn, NegotiationOutcome, SeedAssessment } from "./shared/schemas/negotiation-state.schema.js";
|
|
141
148
|
export type { NegotiationAction, NegotiationSeat, NegotiationProtocolVersion } from "./shared/schemas/negotiation-state.schema.js";
|
|
142
149
|
export type { NegotiationGraphLike } from "./capabilities/negotiation.facade.js";
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export { SYSTEM_AGENT_IDS } from './shared/interfaces/agent.interface.js';
|
|
|
25
25
|
// ─── Shared schemas ───────────────────────────────────────────────────────────
|
|
26
26
|
export { ChatContextDigestSchema } from "./shared/schemas/chat-context.schema.js";
|
|
27
27
|
export { NegotiationQuestionCandidateSchema, NegotiationQuestionProvenanceSchema, } from "./shared/schemas/question.schema.js";
|
|
28
|
+
export { McpAuthInputSchema, McpApiKeyMetadataSchema, McpResolvedIdentitySchema, } from "./shared/schemas/mcp-auth.schema.js";
|
|
28
29
|
export { DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD, resolveAssignmentNetworkScope, buildNetworkAssignmentDecision } from "./shared/assignment/network-assignment.policy.js";
|
|
29
30
|
export { buildCandidateEvidence } from "./capabilities/opportunities.facade.js";
|
|
30
31
|
// ─── Graph factories ──────────────────────────────────────────────────────────
|
|
@@ -45,6 +46,7 @@ export { MaintenanceGraphFactory } from "./capabilities/interaction-composition.
|
|
|
45
46
|
export { NegotiationGraphFactory, negotiateCandidates } from "./capabilities/negotiation.facade.js";
|
|
46
47
|
export { OpportunityGraphFactory } from "./capabilities/opportunities.facade.js";
|
|
47
48
|
export { hasUnsupportedOpportunityClaim } from "./capabilities/opportunities.facade.js";
|
|
49
|
+
export { opportunityOwnerActionForStatus, bindOwnerApprovalProvenance } from "./capabilities/opportunities.facade.js";
|
|
48
50
|
export { EnrichmentGraphFactory } from "./capabilities/participant-context.facade.js";
|
|
49
51
|
export { PremiseGraphFactory } from "./capabilities/participant-context.facade.js";
|
|
50
52
|
// ─── Agents ───────────────────────────────────────────────────────────────────
|
|
@@ -86,6 +88,7 @@ export { OpportunityPresenter, gatherPresenterContext } from "./capabilities/opp
|
|
|
86
88
|
export { canUserSeeOpportunity, isActionableForViewer, validateOpportunityActors, classifyOpportunity, selectByComposition, FEED_SOFT_TARGETS } from "./capabilities/opportunities.facade.js";
|
|
87
89
|
export { getPrimaryActionLabel } from "./capabilities/opportunities.facade.js";
|
|
88
90
|
export { computeFeedHealth } from "./capabilities/opportunities.facade.js";
|
|
91
|
+
export { isIntroducerDiscoveryEnabled } from "./capabilities/opportunities.facade.js";
|
|
89
92
|
export { selectContactsForDiscovery, shouldRunIntroducerDiscovery, runIntroducerDiscovery, MAX_CONTACTS_PER_CYCLE, MAX_CANDIDATES_PER_CONTACT, INTRODUCER_DISCOVERY_SOURCE } from "./capabilities/opportunities.facade.js";
|
|
90
93
|
export { persistOpportunities } from "./capabilities/opportunities.facade.js";
|
|
91
94
|
export { presentOpportunity } from "./capabilities/opportunities.facade.js";
|
|
@@ -111,6 +114,8 @@ export { AMBIENT_PARK_WINDOW_MS } from './capabilities/negotiation.facade.js';
|
|
|
111
114
|
export { normalizeTelegramHandle } from './shared/utils/telegram-handle.js';
|
|
112
115
|
// ─── MCP ──────────────────────────────────────────────────────────────────────
|
|
113
116
|
export { createMcpServer, buildMcpOnboardingMessage, ONBOARDING_ALLOWED } from "./mcp/mcp.server.js";
|
|
117
|
+
export { MCP_AGENT_ADMIN_TOOLS, CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS, CANONICAL_MCP_TOOL_ACCESS_RULES, MCP_INFORMATIONAL_TOOLS, MCP_PERMISSION_ACTIONS, McpCapabilityPolicy, McpCapabilitySubjectSchema, McpPermissionActionSchema, McpPolicyAgentSnapshotSchema, McpPrincipalProfileSchema, McpToolPermissionRequirementSchema, McpToolAccessRuleSchema, buildMcpAuthorizationDenialEvent, defineMcpToolAccessRules, defineMcpToolPermissionMap, resolveMcpActivityCaller, resolveMcpCapabilitySubject, } from "./mcp/mcp.authorization-policy.js";
|
|
118
|
+
export { ActivityQuestionCountsSchema, ActivityQuestionDomainSchema, ActivitySummaryDomainSchema, ActivitySummaryResponseSchema, McpActivityCallerSchema, QUESTION_MODE_TO_DOMAIN, READ_ACTIVITY_SUMMARY_TOOL_NAME, activitySummaryNetworkId, projectActivitySummary, resolveActivitySummaryDomains, } from "./shared/agent/activity-projection.js";
|
|
114
119
|
// ─── Negotiation seat rules (v2 client-advocate protocol) ───────────────────
|
|
115
120
|
export { allowedActionsFor, isTerminalAction, isRejectLikeAction, readProtocolVersion, resolveSeat, seatViolationMessage } from "./capabilities/negotiation.facade.js";
|
|
116
121
|
export { assessConsultationEligibility, consultationPromptFor, negotiationConsultationPolicyMode } from "./capabilities/negotiation.facade.js";
|
|
@@ -11,6 +11,7 @@ import { MaintenanceGraphState } from './maintenance.state.js';
|
|
|
11
11
|
import { computeFeedHealth } from '../opportunity/feed/feed.health.js';
|
|
12
12
|
import { canUserSeeOpportunity, classifyOpportunity, isActionableForViewer, FEED_SOFT_TARGETS } from '../opportunity/opportunity.utils.js';
|
|
13
13
|
import { shouldRunIntroducerDiscovery, runIntroducerDiscovery } from '../opportunity/opportunity.introducer.js';
|
|
14
|
+
import { isIntroducerDiscoveryEnabled } from '../opportunity/application/opportunity.introducer-feature.js';
|
|
14
15
|
import { protocolLogger } from '../shared/observability/protocol.logger.js';
|
|
15
16
|
const logger = protocolLogger('MaintenanceGraph');
|
|
16
17
|
const FRESHNESS_WINDOW_MS = 12 * 60 * 60 * 1000; // 12 hours
|
|
@@ -132,6 +133,12 @@ export class MaintenanceGraphFactory {
|
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
135
|
const introducerDiscoveryNode = async (state) => {
|
|
136
|
+
if (!isIntroducerDiscoveryEnabled()) {
|
|
137
|
+
logger.info('Introducer discovery skipped — disabled by configuration', {
|
|
138
|
+
userId: state.userId,
|
|
139
|
+
});
|
|
140
|
+
return {};
|
|
141
|
+
}
|
|
135
142
|
try {
|
|
136
143
|
const connectorFlowTarget = FEED_SOFT_TARGETS.connectorFlow;
|
|
137
144
|
if (!shouldRunIntroducerDiscovery(state.connectorFlowCount, connectorFlowTarget)) {
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { McpResolvedIdentity } from '../shared/schemas/mcp-auth.schema.js';
|
|
3
|
+
import type { McpActivityCaller } from '../shared/agent/activity-projection.js';
|
|
4
|
+
/** Canonical MCP permission actions. */
|
|
5
|
+
export declare const MCP_PERMISSION_ACTIONS: readonly ["manage:identity", "manage:premises", "manage:intents", "manage:networks", "manage:opportunities", "manage:negotiations"];
|
|
6
|
+
export declare const McpPermissionActionSchema: z.ZodEnum<["manage:identity", "manage:premises", "manage:intents", "manage:networks", "manage:opportunities", "manage:negotiations"]>;
|
|
7
|
+
export type McpPermissionAction = z.infer<typeof McpPermissionActionSchema>;
|
|
8
|
+
export declare const McpToolPermissionRequirementSchema: z.ZodObject<{
|
|
9
|
+
action: z.ZodEnum<["manage:identity", "manage:premises", "manage:intents", "manage:networks", "manage:opportunities", "manage:negotiations"]>;
|
|
10
|
+
/**
|
|
11
|
+
* Capability reach only. Entity ownership, membership, approval, and exact
|
|
12
|
+
* scope checks remain in the capability handler.
|
|
13
|
+
*/
|
|
14
|
+
reach: z.ZodDefault<z.ZodEnum<["principal", "network"]>>;
|
|
15
|
+
}, "strict", z.ZodTypeAny, {
|
|
16
|
+
action: "manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks";
|
|
17
|
+
reach: "network" | "principal";
|
|
18
|
+
}, {
|
|
19
|
+
action: "manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks";
|
|
20
|
+
reach?: "network" | "principal" | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type McpToolPermissionRequirement = z.infer<typeof McpToolPermissionRequirementSchema>;
|
|
23
|
+
export type McpToolPermissionMap = ReadonlyMap<string, McpToolPermissionRequirement>;
|
|
24
|
+
/**
|
|
25
|
+
* Runtime-validates a capability-owned tool-to-permission mapping.
|
|
26
|
+
*/
|
|
27
|
+
export declare function defineMcpToolPermissionMap(mapping: Readonly<Record<string, McpToolPermissionRequirement>>): McpToolPermissionMap;
|
|
28
|
+
export declare const McpToolAccessRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
29
|
+
access: z.ZodEnum<["permission", "authenticated", "human_only", "agent_admin", "informational", "delivery_only", "removed"]>;
|
|
30
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodEnum<["manage:identity", "manage:premises", "manage:intents", "manage:networks", "manage:opportunities", "manage:negotiations"]>, "many">>;
|
|
31
|
+
reach: z.ZodEnum<["principal", "network"]>;
|
|
32
|
+
}, "strict", z.ZodTypeAny, {
|
|
33
|
+
reach: "network" | "principal";
|
|
34
|
+
access: "removed" | "permission" | "authenticated" | "human_only" | "agent_admin" | "informational" | "delivery_only";
|
|
35
|
+
actions?: ("manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks")[] | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
reach: "network" | "principal";
|
|
38
|
+
access: "removed" | "permission" | "authenticated" | "human_only" | "agent_admin" | "informational" | "delivery_only";
|
|
39
|
+
actions?: ("manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks")[] | undefined;
|
|
40
|
+
}>, {
|
|
41
|
+
reach: "network" | "principal";
|
|
42
|
+
access: "removed" | "permission" | "authenticated" | "human_only" | "agent_admin" | "informational" | "delivery_only";
|
|
43
|
+
actions?: ("manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks")[] | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
reach: "network" | "principal";
|
|
46
|
+
access: "removed" | "permission" | "authenticated" | "human_only" | "agent_admin" | "informational" | "delivery_only";
|
|
47
|
+
actions?: ("manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks")[] | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
export type McpToolAccessRule = z.infer<typeof McpToolAccessRuleSchema>;
|
|
50
|
+
export type McpToolAccessRuleMap = ReadonlyMap<string, McpToolAccessRule>;
|
|
51
|
+
/** Runtime-validates a complete static MCP tool access matrix. */
|
|
52
|
+
export declare function defineMcpToolAccessRules(rules: Readonly<Record<string, McpToolAccessRule>>): McpToolAccessRuleMap;
|
|
53
|
+
/**
|
|
54
|
+
* Canonical MCP tool authorization matrix.
|
|
55
|
+
*
|
|
56
|
+
* Every tool registered by `createToolRegistry` is classified. Tool handlers
|
|
57
|
+
* retain domain ownership, membership, exact-scope, and approval checks.
|
|
58
|
+
*/
|
|
59
|
+
export declare const CANONICAL_MCP_TOOL_ACCESS_RULES: McpToolAccessRuleMap;
|
|
60
|
+
/** Tools visible while a session-authenticated human completes onboarding. */
|
|
61
|
+
export declare const ONBOARDING_ALLOWED: ReadonlySet<string>;
|
|
62
|
+
/** Agent administration inventory. */
|
|
63
|
+
export declare const MCP_AGENT_ADMIN_TOOLS: ReadonlySet<string>;
|
|
64
|
+
/** Informational inventory retained as a convenience export. */
|
|
65
|
+
export declare const MCP_INFORMATIONAL_TOOLS: ReadonlySet<string>;
|
|
66
|
+
export declare const McpPolicyAgentSnapshotSchema: z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
ownerId: z.ZodString;
|
|
69
|
+
type: z.ZodEnum<["personal", "external", "system"]>;
|
|
70
|
+
status: z.ZodEnum<["active", "inactive"]>;
|
|
71
|
+
permissions: z.ZodArray<z.ZodObject<{
|
|
72
|
+
agentId: z.ZodString;
|
|
73
|
+
userId: z.ZodString;
|
|
74
|
+
scope: z.ZodEnum<["global", "node", "network"]>;
|
|
75
|
+
scopeId: z.ZodNullable<z.ZodString>;
|
|
76
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
77
|
+
}, "strict", z.ZodTypeAny, {
|
|
78
|
+
userId: string;
|
|
79
|
+
scope: "network" | "global" | "node";
|
|
80
|
+
scopeId: string | null;
|
|
81
|
+
agentId: string;
|
|
82
|
+
actions: string[];
|
|
83
|
+
}, {
|
|
84
|
+
userId: string;
|
|
85
|
+
scope: "network" | "global" | "node";
|
|
86
|
+
scopeId: string | null;
|
|
87
|
+
agentId: string;
|
|
88
|
+
actions: string[];
|
|
89
|
+
}>, "many">;
|
|
90
|
+
}, "strict", z.ZodTypeAny, {
|
|
91
|
+
id: string;
|
|
92
|
+
type: "system" | "personal" | "external";
|
|
93
|
+
status: "active" | "inactive";
|
|
94
|
+
ownerId: string;
|
|
95
|
+
permissions: {
|
|
96
|
+
userId: string;
|
|
97
|
+
scope: "network" | "global" | "node";
|
|
98
|
+
scopeId: string | null;
|
|
99
|
+
agentId: string;
|
|
100
|
+
actions: string[];
|
|
101
|
+
}[];
|
|
102
|
+
}, {
|
|
103
|
+
id: string;
|
|
104
|
+
type: "system" | "personal" | "external";
|
|
105
|
+
status: "active" | "inactive";
|
|
106
|
+
ownerId: string;
|
|
107
|
+
permissions: {
|
|
108
|
+
userId: string;
|
|
109
|
+
scope: "network" | "global" | "node";
|
|
110
|
+
scopeId: string | null;
|
|
111
|
+
agentId: string;
|
|
112
|
+
actions: string[];
|
|
113
|
+
}[];
|
|
114
|
+
}>;
|
|
115
|
+
export type McpPolicyAgentSnapshot = z.infer<typeof McpPolicyAgentSnapshotSchema>;
|
|
116
|
+
export declare const McpPrincipalProfileSchema: z.ZodEnum<["session_human", "onboarding_human", "enrollment_key", "unregistered_key", "registered_global_agent", "registered_network_agent", "delivery_agent", "invalid_agent"]>;
|
|
117
|
+
export type McpPrincipalProfile = z.infer<typeof McpPrincipalProfileSchema>;
|
|
118
|
+
export declare const McpCapabilitySubjectSchema: z.ZodObject<{
|
|
119
|
+
profile: z.ZodEnum<["session_human", "onboarding_human", "enrollment_key", "unregistered_key", "registered_global_agent", "registered_network_agent", "delivery_agent", "invalid_agent"]>;
|
|
120
|
+
userId: z.ZodString;
|
|
121
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
122
|
+
agentType: z.ZodOptional<z.ZodEnum<["personal", "external", "system"]>>;
|
|
123
|
+
isOnboarding: z.ZodBoolean;
|
|
124
|
+
networkScopeId: z.ZodNullable<z.ZodString>;
|
|
125
|
+
permissions: z.ZodArray<z.ZodEnum<["manage:identity", "manage:premises", "manage:intents", "manage:networks", "manage:opportunities", "manage:negotiations"]>, "many">;
|
|
126
|
+
}, "strict", z.ZodTypeAny, {
|
|
127
|
+
userId: string;
|
|
128
|
+
profile: "session_human" | "onboarding_human" | "enrollment_key" | "unregistered_key" | "registered_global_agent" | "registered_network_agent" | "delivery_agent" | "invalid_agent";
|
|
129
|
+
permissions: ("manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks")[];
|
|
130
|
+
networkScopeId: string | null;
|
|
131
|
+
isOnboarding: boolean;
|
|
132
|
+
agentId?: string | undefined;
|
|
133
|
+
agentType?: "system" | "personal" | "external" | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
userId: string;
|
|
136
|
+
profile: "session_human" | "onboarding_human" | "enrollment_key" | "unregistered_key" | "registered_global_agent" | "registered_network_agent" | "delivery_agent" | "invalid_agent";
|
|
137
|
+
permissions: ("manage:negotiations" | "manage:intents" | "manage:opportunities" | "manage:identity" | "manage:premises" | "manage:networks")[];
|
|
138
|
+
networkScopeId: string | null;
|
|
139
|
+
isOnboarding: boolean;
|
|
140
|
+
agentId?: string | undefined;
|
|
141
|
+
agentType?: "system" | "personal" | "external" | undefined;
|
|
142
|
+
}>;
|
|
143
|
+
export type McpCapabilitySubject = z.infer<typeof McpCapabilitySubjectSchema>;
|
|
144
|
+
export type ResolveMcpCapabilitySubjectInput = {
|
|
145
|
+
identity: McpResolvedIdentity;
|
|
146
|
+
isOnboarding: boolean;
|
|
147
|
+
agent?: McpPolicyAgentSnapshot | null;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Central capability-loading interpretation of a stored permission row's raw
|
|
151
|
+
* actions. Canonical actions pass through; retired actions project per
|
|
152
|
+
* {@link LEGACY_STORED_ACTION_PROJECTION}; every unknown action fails closed
|
|
153
|
+
* (ignored). Owner/scope matching is applied by the caller BEFORE this runs, so
|
|
154
|
+
* this function never widens the scope a grant applies to.
|
|
155
|
+
*/
|
|
156
|
+
export declare function projectStoredPermissionActions(actions: readonly string[]): McpPermissionAction[];
|
|
157
|
+
/**
|
|
158
|
+
* Resolves a request-local, runtime-validated principal profile.
|
|
159
|
+
*/
|
|
160
|
+
export declare function resolveMcpCapabilitySubject(input: ResolveMcpCapabilitySubjectInput): McpCapabilitySubject;
|
|
161
|
+
/**
|
|
162
|
+
* Maps a resolved capability subject to the typed caller context consumed by
|
|
163
|
+
* the centralized activity-summary projection. Session and onboarding humans
|
|
164
|
+
* own the summarized data and receive the full owner view; every other
|
|
165
|
+
* profile is projected as an agent bounded by its granted permissions and
|
|
166
|
+
* (for network agents) its bound community.
|
|
167
|
+
*/
|
|
168
|
+
export declare function resolveMcpActivityCaller(subject: McpCapabilitySubject): McpActivityCaller;
|
|
169
|
+
export declare const McpCapabilityDecisionReasonSchema: z.ZodEnum<["session_human", "onboarding", "enrollment", "authenticated", "agent_self_read", "informational", "permission_granted", "delivery", "onboarding_required", "enrollment_required", "unregistered_principal", "invalid_agent", "agent_admin_denied", "human_read_own_agent_denied", "human_only", "permission_missing", "delivery_required", "removed", "tool_unclassified"]>;
|
|
170
|
+
export type McpCapabilityDecision = {
|
|
171
|
+
allowed: boolean;
|
|
172
|
+
reason: z.infer<typeof McpCapabilityDecisionReasonSchema>;
|
|
173
|
+
reach?: 'principal' | 'network';
|
|
174
|
+
requiredPermissions?: McpPermissionAction[];
|
|
175
|
+
};
|
|
176
|
+
export type McpCapabilityDecisionReason = z.infer<typeof McpCapabilityDecisionReasonSchema>;
|
|
177
|
+
/**
|
|
178
|
+
* Safe, host-facing description of a single authorization denial. It carries
|
|
179
|
+
* ONLY the caller profile, the tool, and the policy reason/reach — never a
|
|
180
|
+
* token, API key, bearer credential, raw header, or tool-argument payload.
|
|
181
|
+
* `userId`/`agentId`/`networkScopeId` are opaque principal identifiers, not
|
|
182
|
+
* secrets. Constructed centrally in {@link buildMcpAuthorizationDenialEvent}
|
|
183
|
+
* so no call site can widen it with sensitive fields.
|
|
184
|
+
*/
|
|
185
|
+
export type McpAuthorizationDenialEvent = {
|
|
186
|
+
/** Which JSON-RPC boundary produced the denial. */
|
|
187
|
+
phase: 'tools/call' | 'tools/list';
|
|
188
|
+
/** The classified tool the caller attempted. */
|
|
189
|
+
toolName: string;
|
|
190
|
+
/** The resolved principal profile (never the credential that produced it). */
|
|
191
|
+
profile: McpPrincipalProfile;
|
|
192
|
+
/** The policy decision reason. */
|
|
193
|
+
reason: McpCapabilityDecisionReason;
|
|
194
|
+
/** Capability reach of the tool rule, when the rule was found. */
|
|
195
|
+
reach?: 'principal' | 'network';
|
|
196
|
+
/** The any-of permissions the tool required, when applicable. */
|
|
197
|
+
requiredPermissions?: McpPermissionAction[];
|
|
198
|
+
/** Opaque owning-user identifier. */
|
|
199
|
+
userId: string;
|
|
200
|
+
/** Opaque agent identifier, present only for agent principals. */
|
|
201
|
+
agentId?: string;
|
|
202
|
+
/** Bound network scope for network agents; null otherwise. */
|
|
203
|
+
networkScopeId: string | null;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Host-injected authorization observability seam. The protocol emits
|
|
207
|
+
* structured, secret-free denial events at the host boundary; the host decides
|
|
208
|
+
* how to record them. Implementations MUST NOT throw affect the decision — the
|
|
209
|
+
* server calls this defensively and ignores observer failures (fail-closed is
|
|
210
|
+
* preserved regardless).
|
|
211
|
+
*/
|
|
212
|
+
export interface McpAuthorizationObserver {
|
|
213
|
+
onCapabilityDenied(event: McpAuthorizationDenialEvent): void;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Builds a safe denial event from a resolved subject and a denial decision.
|
|
217
|
+
* Only whitelisted, non-sensitive fields are copied across; the caller's
|
|
218
|
+
* granted permissions, credentials, headers, and tool arguments are never
|
|
219
|
+
* included.
|
|
220
|
+
*/
|
|
221
|
+
export declare function buildMcpAuthorizationDenialEvent(input: {
|
|
222
|
+
phase: 'tools/call' | 'tools/list';
|
|
223
|
+
toolName: string;
|
|
224
|
+
subject: McpCapabilitySubject;
|
|
225
|
+
decision: McpCapabilityDecision;
|
|
226
|
+
}): McpAuthorizationDenialEvent;
|
|
227
|
+
export type McpCapabilityPolicyOptions = {
|
|
228
|
+
/** Complete static rule map; defaults to the canonical production matrix. */
|
|
229
|
+
toolRules?: McpToolAccessRuleMap;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Reusable MCP capability policy. It stores static rules only; caller-specific
|
|
233
|
+
* subjects and decisions are never retained.
|
|
234
|
+
*/
|
|
235
|
+
export declare class McpCapabilityPolicy {
|
|
236
|
+
private readonly toolRules;
|
|
237
|
+
constructor(options?: McpCapabilityPolicyOptions);
|
|
238
|
+
/**
|
|
239
|
+
* Decides whether a resolved caller may use one classified tool.
|
|
240
|
+
*/
|
|
241
|
+
authorize(subject: McpCapabilitySubject, toolName: string): McpCapabilityDecision;
|
|
242
|
+
/**
|
|
243
|
+
* Filters a static inventory and returns a fresh, uncached caller list.
|
|
244
|
+
*/
|
|
245
|
+
visibleToolNames(subject: McpCapabilitySubject, toolNames: readonly string[]): string[];
|
|
246
|
+
/** Returns the static classification for inventory tests and host composition. */
|
|
247
|
+
ruleFor(toolName: string): McpToolAccessRule | undefined;
|
|
248
|
+
}
|
|
249
|
+
/** Canonical production options explicitly passed by the host composition. */
|
|
250
|
+
export declare const CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS: McpCapabilityPolicyOptions;
|