@indexnetwork/protocol 4.3.2-rc.306.1 → 4.3.3-rc.308.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/chat.prompt.js +1 -1
- package/dist/chat/chat.prompt.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/intent/intent.graph.d.ts +10 -0
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +6 -2
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/intent/intent.state.d.ts +4 -0
- package/dist/intent/intent.state.d.ts.map +1 -1
- package/dist/intent/intent.state.js +10 -0
- package/dist/intent/intent.state.js.map +1 -1
- package/dist/intent/intent.tools.d.ts.map +1 -1
- package/dist/intent/intent.tools.js +7 -0
- package/dist/intent/intent.tools.js.map +1 -1
- package/dist/mcp/mcp.server.d.ts +11 -13
- package/dist/mcp/mcp.server.d.ts.map +1 -1
- package/dist/mcp/mcp.server.js +30 -29
- package/dist/mcp/mcp.server.js.map +1 -1
- package/dist/network/network.graph.js +2 -2
- package/dist/network/network.graph.js.map +1 -1
- package/dist/opportunity/opportunity.discover.d.ts +5 -0
- package/dist/opportunity/opportunity.discover.d.ts.map +1 -1
- package/dist/opportunity/opportunity.discover.js +3 -0
- package/dist/opportunity/opportunity.discover.js.map +1 -1
- package/dist/opportunity/opportunity.graph.d.ts +6 -6
- package/dist/opportunity/opportunity.pending-questions.d.ts +3 -0
- package/dist/opportunity/opportunity.pending-questions.d.ts.map +1 -1
- package/dist/opportunity/opportunity.pending-questions.js +7 -2
- package/dist/opportunity/opportunity.pending-questions.js.map +1 -1
- package/dist/opportunity/opportunity.state.d.ts +1 -1
- package/dist/opportunity/opportunity.tools.d.ts.map +1 -1
- package/dist/opportunity/opportunity.tools.js +31 -17
- package/dist/opportunity/opportunity.tools.js.map +1 -1
- package/dist/premise/premise.graph.d.ts +13 -1
- package/dist/premise/premise.graph.d.ts.map +1 -1
- package/dist/premise/premise.graph.js +11 -6
- package/dist/premise/premise.graph.js.map +1 -1
- package/dist/premise/premise.state.d.ts +5 -0
- package/dist/premise/premise.state.d.ts.map +1 -1
- package/dist/premise/premise.state.js +11 -0
- package/dist/premise/premise.state.js.map +1 -1
- package/dist/premise/premise.tools.d.ts.map +1 -1
- package/dist/premise/premise.tools.js +5 -0
- package/dist/premise/premise.tools.js.map +1 -1
- package/dist/questioner/questioner.tools.d.ts.map +1 -1
- package/dist/questioner/questioner.tools.js +23 -11
- package/dist/questioner/questioner.tools.js.map +1 -1
- package/dist/questioner/questioner.types.d.ts +5 -0
- package/dist/questioner/questioner.types.d.ts.map +1 -1
- package/dist/questioner/questioner.types.js.map +1 -1
- package/dist/shared/agent/tool.factory.d.ts.map +1 -1
- package/dist/shared/agent/tool.factory.js +24 -14
- package/dist/shared/agent/tool.factory.js.map +1 -1
- package/dist/shared/agent/tool.helpers.d.ts +17 -18
- package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
- package/dist/shared/agent/tool.helpers.js +10 -11
- package/dist/shared/agent/tool.helpers.js.map +1 -1
- package/dist/shared/agent/tool.scope.d.ts +27 -0
- package/dist/shared/agent/tool.scope.d.ts.map +1 -0
- package/dist/shared/agent/tool.scope.js +27 -0
- package/dist/shared/agent/tool.scope.js.map +1 -0
- package/dist/shared/assignment/network-assignment.policy.d.ts +8 -5
- package/dist/shared/assignment/network-assignment.policy.d.ts.map +1 -1
- package/dist/shared/assignment/network-assignment.policy.js +11 -6
- package/dist/shared/assignment/network-assignment.policy.js.map +1 -1
- package/dist/shared/hyde/hyde.graph.d.ts +6 -6
- package/dist/shared/hyde/hyde.state.d.ts +2 -2
- package/dist/shared/interfaces/database.interface.d.ts +15 -3
- package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/database.interface.js.map +1 -1
- package/dist/shared/interfaces/discovery-run.interface.d.ts +1 -1
- package/dist/shared/interfaces/discovery-run.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/discovery-run.interface.js.map +1 -1
- package/dist/shared/interfaces/queue.interface.d.ts +8 -2
- package/dist/shared/interfaces/queue.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/queue.interface.js.map +1 -1
- package/dist/shared/schemas/network-assignment.schema.d.ts +2 -2
- package/dist/shared/schemas/pending-question.schema.d.ts +5 -0
- package/dist/shared/schemas/pending-question.schema.d.ts.map +1 -1
- package/dist/shared/schemas/pending-question.schema.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { requestContext } from "../shared/observability/request-context.js";
|
|
3
3
|
import { success, error, UUID_REGEX } from "../shared/agent/tool.helpers.js";
|
|
4
|
+
import { deriveDiscoveryNetworkIds } from "../shared/agent/tool.scope.js";
|
|
4
5
|
import { MINIMAL_MAIN_TEXT_MAX_CHARS, getPrimaryActionLabel, SECONDARY_ACTION_LABEL } from "./opportunity.labels.js";
|
|
5
6
|
import { viewerCentricCardSummary, narratorRemarkFromReasoning, stripUuids } from "./opportunity.presentation.js";
|
|
6
7
|
import { runDiscoverFromQuery, continueDiscovery } from "./opportunity.discover.js";
|
|
@@ -382,16 +383,20 @@ function discoveryRunSignature(input, scopeKey) {
|
|
|
382
383
|
}
|
|
383
384
|
/**
|
|
384
385
|
* Stable key for the resolved discovery scope of a request. Two requests
|
|
385
|
-
* coalesce only when they resolve to the same
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
386
|
+
* coalesce only when they resolve to the same focused discovery boundary. For
|
|
387
|
+
* scoped contexts, that boundary is the scope envelope (`scopeType`/`scopeId`),
|
|
388
|
+
* not the personal-inclusive allowed network reach used for self-owned writes.
|
|
389
|
+
* When no scope envelope is present, legacy `indexScope` remains part of the
|
|
390
|
+
* key so older contexts with different unscoped reach do not coalesce.
|
|
390
391
|
*/
|
|
391
392
|
function discoveryScopeKey(ctx) {
|
|
392
393
|
return JSON.stringify({
|
|
393
394
|
networkId: (ctx.networkId ?? "").trim(),
|
|
394
|
-
|
|
395
|
+
scopeType: (ctx.scopeType ?? "").trim(),
|
|
396
|
+
scopeId: (ctx.scopeId ?? "").trim(),
|
|
397
|
+
indexScope: ctx.scopeType && ctx.scopeId
|
|
398
|
+
? []
|
|
399
|
+
: [...(ctx.indexScope ?? [])].map((s) => s.trim()).sort(),
|
|
395
400
|
});
|
|
396
401
|
}
|
|
397
402
|
function confirmDeliveryError(code, retryable, message) {
|
|
@@ -458,7 +463,7 @@ export function createOpportunityTools(defineTool, deps) {
|
|
|
458
463
|
networkId: z
|
|
459
464
|
.string()
|
|
460
465
|
.optional()
|
|
461
|
-
.describe("Index UUID to scope discovery to a specific community. Get from read_networks. In an index-scoped chat, omitting this runs discovery
|
|
466
|
+
.describe("Index UUID to scope discovery to a specific community. Get from read_networks. In an index-scoped chat, omitting this runs discovery only in the scoped community; pass the personal index ID (from read_networks, isPersonal=true) only when the user explicitly asks to discover among contacts."),
|
|
462
467
|
intentId: z
|
|
463
468
|
.string()
|
|
464
469
|
.optional()
|
|
@@ -521,11 +526,9 @@ export function createOpportunityTools(defineTool, deps) {
|
|
|
521
526
|
return error(`This chat is scoped to ${context.indexName ?? "this index"}. You can only create opportunities in this community.`);
|
|
522
527
|
}
|
|
523
528
|
// Distinguish an explicit `query.networkId` override (caller wants discovery
|
|
524
|
-
// scoped to one specific index) from an implicit scoped-chat context
|
|
525
|
-
//
|
|
526
|
-
//
|
|
527
|
-
// Conflating them via `context.networkId || query.networkId` made the
|
|
528
|
-
// implicit branch unreachable.
|
|
529
|
+
// scoped to one specific index) from an implicit scoped-chat context.
|
|
530
|
+
// Scoped-chat discovery stays focused to the scoped community only; the
|
|
531
|
+
// personal-inclusive allowed reach is reserved for self-owned writes.
|
|
529
532
|
const explicitIndexId = query.networkId?.trim() || undefined;
|
|
530
533
|
const effectiveIndexId = explicitIndexId;
|
|
531
534
|
if (effectiveIndexId && !UUID_REGEX.test(effectiveIndexId)) {
|
|
@@ -566,6 +569,7 @@ export function createOpportunityTools(defineTool, deps) {
|
|
|
566
569
|
userName: context.userName,
|
|
567
570
|
userEmail: context.userEmail,
|
|
568
571
|
...(context.networkId ? { networkId: context.networkId } : {}),
|
|
572
|
+
...(context.scopeType && context.scopeId ? { scopeType: context.scopeType, scopeId: context.scopeId } : {}),
|
|
569
573
|
...(context.indexName ? { indexName: context.indexName } : {}),
|
|
570
574
|
indexScope: context.indexScope,
|
|
571
575
|
...(context.sessionId ? { sessionId: context.sessionId } : {}),
|
|
@@ -863,12 +867,20 @@ export function createOpportunityTools(defineTool, deps) {
|
|
|
863
867
|
}
|
|
864
868
|
indexScope = [effectiveIndexId];
|
|
865
869
|
}
|
|
870
|
+
else if (context.scopeType === 'network' && context.scopeId) {
|
|
871
|
+
// Scoped chat: discovery is focused-network only. Self-owned writes may
|
|
872
|
+
// include personal indexes, but opportunity visibility must not.
|
|
873
|
+
const scopedDiscoveryIds = deriveDiscoveryNetworkIds({
|
|
874
|
+
memberships: context.userNetworks,
|
|
875
|
+
scopeType: context.scopeType,
|
|
876
|
+
scopeId: context.scopeId,
|
|
877
|
+
});
|
|
878
|
+
indexScope = scopedDiscoveryIds;
|
|
879
|
+
}
|
|
866
880
|
else if (context.networkId) {
|
|
867
|
-
//
|
|
868
|
-
//
|
|
869
|
-
indexScope = context.
|
|
870
|
-
? [...context.indexScope]
|
|
871
|
-
: [context.networkId];
|
|
881
|
+
// Legacy scoped context without a scope envelope: preserve focused-only
|
|
882
|
+
// discovery using the focused network id.
|
|
883
|
+
indexScope = [context.networkId];
|
|
872
884
|
}
|
|
873
885
|
else {
|
|
874
886
|
// No scope - use all indexes (only in unscoped chat)
|
|
@@ -933,6 +945,7 @@ export function createOpportunityTools(defineTool, deps) {
|
|
|
933
945
|
...(deps.chatSummary && { chatSummary: deps.chatSummary }),
|
|
934
946
|
...(deps.questionGenerator && { questionGenerator: deps.questionGenerator }),
|
|
935
947
|
...(deps.questionerEnqueue && { questionerEnqueue: deps.questionerEnqueue }),
|
|
948
|
+
...(context.scopeType && context.scopeId ? { scopeType: context.scopeType, scopeId: context.scopeId } : {}),
|
|
936
949
|
...(deps.negotiationSummary && { negotiationSummary: deps.negotiationSummary }),
|
|
937
950
|
// Decision questions add an LLM call after the negotiation phase.
|
|
938
951
|
// Capped at DISCOVERY_QUESTIONS_TIMEOUT_MS (12 s default,
|
|
@@ -956,6 +969,7 @@ export function createOpportunityTools(defineTool, deps) {
|
|
|
956
969
|
findPendingQuestions: deps.findPendingQuestions,
|
|
957
970
|
userId: context.userId,
|
|
958
971
|
sourceType: 'discovery',
|
|
972
|
+
...(context.scopeType === 'network' && context.scopeId ? { networkId: context.scopeId } : {}),
|
|
959
973
|
surfacedQuestionIds: new Set(), // Dedup handled at chat.agent level
|
|
960
974
|
});
|
|
961
975
|
const pendingQuestions = pendingQuestionResult.questions;
|