@indexnetwork/protocol 3.7.0-rc.277.1 → 3.7.1-rc.279.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/agent/agent.tools.js +1 -1
- package/dist/agent/agent.tools.js.map +1 -1
- package/dist/chat/chat.agent.d.ts +6 -6
- package/dist/chat/chat.agent.d.ts.map +1 -1
- package/dist/chat/chat.agent.js +10 -9
- package/dist/chat/chat.agent.js.map +1 -1
- package/dist/chat/chat.graph.d.ts.map +1 -1
- package/dist/chat/chat.graph.js +3 -12
- package/dist/chat/chat.graph.js.map +1 -1
- package/dist/chat/chat.interrupt.classifier.d.ts.map +1 -1
- package/dist/chat/chat.interrupt.classifier.js +1 -3
- package/dist/chat/chat.interrupt.classifier.js.map +1 -1
- package/dist/chat/chat.prompt.d.ts.map +1 -1
- package/dist/chat/chat.prompt.js +8 -7
- package/dist/chat/chat.prompt.js.map +1 -1
- package/dist/chat/chat.prompt.modules.d.ts.map +1 -1
- package/dist/chat/chat.prompt.modules.js +5 -0
- package/dist/chat/chat.prompt.modules.js.map +1 -1
- package/dist/chat/chat.suggester.js.map +1 -1
- package/dist/context/context.generator.d.ts +2 -0
- package/dist/context/context.generator.d.ts.map +1 -1
- package/dist/context/context.generator.js +8 -6
- package/dist/context/context.generator.js.map +1 -1
- package/dist/intent/intent.clarifier.d.ts +2 -0
- package/dist/intent/intent.clarifier.d.ts.map +1 -1
- package/dist/intent/intent.clarifier.js +9 -23
- package/dist/intent/intent.clarifier.js.map +1 -1
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +29 -26
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/intent/intent.tools.d.ts.map +1 -1
- package/dist/intent/intent.tools.js +18 -48
- package/dist/intent/intent.tools.js.map +1 -1
- package/dist/maintenance/maintenance.graph.d.ts.map +1 -1
- package/dist/maintenance/maintenance.graph.js +1 -2
- package/dist/maintenance/maintenance.graph.js.map +1 -1
- package/dist/mcp/mcp.server.d.ts.map +1 -1
- package/dist/mcp/mcp.server.js +3 -5
- package/dist/mcp/mcp.server.js.map +1 -1
- package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
- package/dist/negotiation/negotiation.graph.js +13 -20
- package/dist/negotiation/negotiation.graph.js.map +1 -1
- package/dist/negotiation/negotiation.tools.d.ts.map +1 -1
- package/dist/negotiation/negotiation.tools.js +12 -12
- package/dist/negotiation/negotiation.tools.js.map +1 -1
- package/dist/network/indexer/indexer.graph.d.ts +9 -9
- package/dist/network/indexer/indexer.graph.d.ts.map +1 -1
- package/dist/network/indexer/indexer.graph.js.map +1 -1
- package/dist/network/network.graph.d.ts.map +1 -1
- package/dist/network/network.graph.js +19 -25
- package/dist/network/network.graph.js.map +1 -1
- package/dist/opportunity/feed/feed.categorizer.d.ts.map +1 -1
- package/dist/opportunity/feed/feed.categorizer.js +15 -20
- package/dist/opportunity/feed/feed.categorizer.js.map +1 -1
- package/dist/opportunity/feed/feed.graph.d.ts.map +1 -1
- package/dist/opportunity/feed/feed.graph.js +8 -10
- package/dist/opportunity/feed/feed.graph.js.map +1 -1
- package/dist/opportunity/opportunity.introducer.d.ts.map +1 -1
- package/dist/opportunity/opportunity.introducer.js +1 -2
- package/dist/opportunity/opportunity.introducer.js.map +1 -1
- package/dist/opportunity/opportunity.tools.d.ts.map +1 -1
- package/dist/opportunity/opportunity.tools.js +3 -2
- package/dist/opportunity/opportunity.tools.js.map +1 -1
- package/dist/profile/profile.enricher.d.ts +5 -7
- package/dist/profile/profile.enricher.d.ts.map +1 -1
- package/dist/profile/profile.enricher.js +8 -10
- package/dist/profile/profile.enricher.js.map +1 -1
- package/dist/profile/profile.generator.d.ts.map +1 -1
- package/dist/profile/profile.generator.js +1 -2
- package/dist/profile/profile.generator.js.map +1 -1
- package/dist/profile/profile.tools.js +1 -1
- package/dist/profile/profile.tools.js.map +1 -1
- package/dist/questioner/questioner.presets.d.ts.map +1 -1
- package/dist/questioner/questioner.presets.js +24 -38
- package/dist/questioner/questioner.presets.js.map +1 -1
- package/dist/shared/agent/tool.factory.d.ts.map +1 -1
- package/dist/shared/agent/tool.factory.js +2 -2
- package/dist/shared/agent/tool.factory.js.map +1 -1
- package/dist/shared/agent/tool.helpers.d.ts +10 -0
- package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
- package/dist/shared/agent/tool.helpers.js +2 -1
- package/dist/shared/agent/tool.helpers.js.map +1 -1
- package/dist/shared/agent/tool.runtime.d.ts.map +1 -1
- package/dist/shared/agent/tool.runtime.js +20 -13
- package/dist/shared/agent/tool.runtime.js.map +1 -1
- package/dist/shared/hyde/hyde.graph.d.ts.map +1 -1
- package/dist/shared/hyde/hyde.graph.js +3 -2
- package/dist/shared/hyde/hyde.graph.js.map +1 -1
- package/dist/shared/hyde/hyde.strategies.d.ts +2 -1
- package/dist/shared/hyde/hyde.strategies.d.ts.map +1 -1
- package/dist/shared/hyde/hyde.strategies.js.map +1 -1
- package/dist/shared/observability/trace.d.ts +3 -3
- package/dist/shared/observability/trace.d.ts.map +1 -1
- package/dist/shared/observability/trace.js +19 -33
- package/dist/shared/observability/trace.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { DEFAULT_SPECIFICITY_WARNING } from "./intent.specificity.js";
|
|
3
3
|
import { protocolLogger } from "../shared/observability/protocol.logger.js";
|
|
4
|
-
import {
|
|
4
|
+
import { traceGraph } from "../shared/observability/trace.js";
|
|
5
5
|
import { success, error, UUID_REGEX } from "../shared/agent/tool.helpers.js";
|
|
6
6
|
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
7
7
|
const logger = protocolLogger("ChatTools:Intent");
|
|
@@ -146,11 +146,8 @@ export function createIntentTools(defineTool, deps) {
|
|
|
146
146
|
graphInput.allUserIntents = true;
|
|
147
147
|
}
|
|
148
148
|
const _readIntentGraphStart = Date.now();
|
|
149
|
-
const
|
|
150
|
-
_readIntentTraceEmitter?.({ type: "graph_start", name: "intent" });
|
|
151
|
-
const result = await invokeWithAbortSignal(graphs.intent, graphInput);
|
|
149
|
+
const result = await traceGraph("intent", () => invokeWithAbortSignal(graphs.intent, graphInput));
|
|
152
150
|
const _readIntentGraphMs = Date.now() - _readIntentGraphStart;
|
|
153
|
-
_readIntentTraceEmitter?.({ type: "graph_end", name: "intent", durationMs: _readIntentGraphMs });
|
|
154
151
|
if (result.readResult) {
|
|
155
152
|
if (result.readResult.count === 0 && result.readResult.message && /not a member|Network not found/i.test(result.readResult.message)) {
|
|
156
153
|
return error(result.readResult.message);
|
|
@@ -219,27 +216,21 @@ export function createIntentTools(defineTool, deps) {
|
|
|
219
216
|
const effectiveIndexId = context.networkId || query.networkId?.trim() || undefined;
|
|
220
217
|
// Fetch profile (the intent graph needs it for inference)
|
|
221
218
|
const _profileGraphStart1 = Date.now();
|
|
222
|
-
const
|
|
223
|
-
_createIntentProfileTraceEmitter?.({ type: "graph_start", name: "profile" });
|
|
224
|
-
const profileResult = await invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' });
|
|
219
|
+
const profileResult = await traceGraph("profile", () => invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' }));
|
|
225
220
|
const _profileGraphMs1 = Date.now() - _profileGraphStart1;
|
|
226
|
-
_createIntentProfileTraceEmitter?.({ type: "graph_end", name: "profile", durationMs: _profileGraphMs1 });
|
|
227
221
|
const latestUser = profileResult.profile ? undefined : typeof userDb.getUser === "function" ? await userDb.getUser() : context.user;
|
|
228
222
|
const approvedProfileFallback = profileResult.profile ? "" : buildApprovedProfileFallback(latestUser);
|
|
229
223
|
const userProfile = profileResult.profile ? JSON.stringify(profileResult.profile) : approvedProfileFallback;
|
|
230
224
|
// Run inference + verification only (propose mode — no DB persistence)
|
|
231
225
|
const _intentGraphStart1 = Date.now();
|
|
232
|
-
const
|
|
233
|
-
_createIntentTraceEmitter?.({ type: "graph_start", name: "intent" });
|
|
234
|
-
const result = await invokeWithAbortSignal(graphs.intent, {
|
|
226
|
+
const result = await traceGraph("intent", () => invokeWithAbortSignal(graphs.intent, {
|
|
235
227
|
userId: context.userId,
|
|
236
228
|
userProfile,
|
|
237
229
|
inputContent: query.description,
|
|
238
230
|
operationMode: 'propose',
|
|
239
231
|
...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),
|
|
240
|
-
});
|
|
232
|
+
}));
|
|
241
233
|
const _intentGraphMs1 = Date.now() - _intentGraphStart1;
|
|
242
|
-
_createIntentTraceEmitter?.({ type: "graph_end", name: "intent", durationMs: _intentGraphMs1 });
|
|
243
234
|
logger.debug("Intent graph propose response", { result });
|
|
244
235
|
const verified = result.verifiedIntents || [];
|
|
245
236
|
// MCP contexts have no interactive UI for proposal cards — default to auto-approve
|
|
@@ -286,17 +277,14 @@ export function createIntentTools(defineTool, deps) {
|
|
|
286
277
|
const createTimings = [];
|
|
287
278
|
for (const v of verified) {
|
|
288
279
|
const _createGraphStart = Date.now();
|
|
289
|
-
const
|
|
290
|
-
_createTraceEmitter?.({ type: "graph_start", name: "intent" });
|
|
291
|
-
const createResult = await invokeWithAbortSignal(graphs.intent, {
|
|
280
|
+
const createResult = await traceGraph("intent", () => invokeWithAbortSignal(graphs.intent, {
|
|
292
281
|
userId: context.userId,
|
|
293
282
|
userProfile,
|
|
294
283
|
inputContent: v.description,
|
|
295
284
|
operationMode: 'create',
|
|
296
285
|
...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),
|
|
297
|
-
});
|
|
286
|
+
}));
|
|
298
287
|
const _createGraphMs = Date.now() - _createGraphStart;
|
|
299
|
-
_createTraceEmitter?.({ type: "graph_end", name: "intent", durationMs: _createGraphMs });
|
|
300
288
|
createTimings.push({ name: 'intent-create', durationMs: _createGraphMs, agents: createResult.agentTimings ?? [] });
|
|
301
289
|
const succeeded = createResult.executionResults?.some((r) => r.success);
|
|
302
290
|
if (succeeded) {
|
|
@@ -391,27 +379,21 @@ export function createIntentTools(defineTool, deps) {
|
|
|
391
379
|
}
|
|
392
380
|
}
|
|
393
381
|
const _profileGraphStart2 = Date.now();
|
|
394
|
-
const
|
|
395
|
-
_updateIntentProfileTraceEmitter?.({ type: "graph_start", name: "profile" });
|
|
396
|
-
const profileResult = await invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' });
|
|
382
|
+
const profileResult = await traceGraph("profile", () => invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' }));
|
|
397
383
|
const _profileGraphMs2 = Date.now() - _profileGraphStart2;
|
|
398
|
-
_updateIntentProfileTraceEmitter?.({ type: "graph_end", name: "profile", durationMs: _profileGraphMs2 });
|
|
399
384
|
const latestUser = profileResult.profile ? undefined : typeof userDb.getUser === "function" ? await userDb.getUser() : context.user;
|
|
400
385
|
const approvedProfileFallback = profileResult.profile ? "" : buildApprovedProfileFallback(latestUser);
|
|
401
386
|
const userProfile = profileResult.profile ? JSON.stringify(profileResult.profile) : approvedProfileFallback;
|
|
402
387
|
const _intentGraphStart2 = Date.now();
|
|
403
|
-
const
|
|
404
|
-
_updateIntentTraceEmitter?.({ type: "graph_start", name: "intent" });
|
|
405
|
-
const result = await invokeWithAbortSignal(graphs.intent, {
|
|
388
|
+
const result = await traceGraph("intent", () => invokeWithAbortSignal(graphs.intent, {
|
|
406
389
|
userId: context.userId,
|
|
407
390
|
userProfile,
|
|
408
391
|
operationMode: 'update',
|
|
409
392
|
inputContent: query.description,
|
|
410
393
|
targetIntentIds: [intentId],
|
|
411
394
|
...(context.networkId && { networkId: context.networkId }),
|
|
412
|
-
});
|
|
395
|
+
}));
|
|
413
396
|
const _intentGraphMs2 = Date.now() - _intentGraphStart2;
|
|
414
|
-
_updateIntentTraceEmitter?.({ type: "graph_end", name: "intent", durationMs: _intentGraphMs2 });
|
|
415
397
|
if (result.executionResults?.some((r) => !r.success)) {
|
|
416
398
|
return error("Failed to update intent.");
|
|
417
399
|
}
|
|
@@ -461,17 +443,14 @@ export function createIntentTools(defineTool, deps) {
|
|
|
461
443
|
}
|
|
462
444
|
}
|
|
463
445
|
const _deleteIntentGraphStart = Date.now();
|
|
464
|
-
const
|
|
465
|
-
_deleteIntentTraceEmitter?.({ type: "graph_start", name: "intent" });
|
|
466
|
-
const result = await invokeWithAbortSignal(graphs.intent, {
|
|
446
|
+
const result = await traceGraph("intent", () => invokeWithAbortSignal(graphs.intent, {
|
|
467
447
|
userId: context.userId,
|
|
468
448
|
userProfile: "",
|
|
469
449
|
operationMode: 'delete',
|
|
470
450
|
targetIntentIds: [intentId],
|
|
471
451
|
...(context.networkId && { networkId: context.networkId }),
|
|
472
|
-
});
|
|
452
|
+
}));
|
|
473
453
|
const _deleteIntentGraphMs = Date.now() - _deleteIntentGraphStart;
|
|
474
|
-
_deleteIntentTraceEmitter?.({ type: "graph_end", name: "intent", durationMs: _deleteIntentGraphMs });
|
|
475
454
|
if (result.executionResults?.some((r) => !r.success)) {
|
|
476
455
|
return error("Failed to delete intent.");
|
|
477
456
|
}
|
|
@@ -509,17 +488,14 @@ export function createIntentTools(defineTool, deps) {
|
|
|
509
488
|
return error(`This chat is scoped to ${context.indexName ?? 'this index'}. You can only link intents to this community.`);
|
|
510
489
|
}
|
|
511
490
|
const _createIntentIndexGraphStart = Date.now();
|
|
512
|
-
const
|
|
513
|
-
_createIntentIndexTraceEmitter?.({ type: "graph_start", name: "intent_network" });
|
|
514
|
-
const result = await invokeWithAbortSignal(graphs.intentIndex, {
|
|
491
|
+
const result = await traceGraph("intent_network", () => invokeWithAbortSignal(graphs.intentIndex, {
|
|
515
492
|
userId: context.userId,
|
|
516
493
|
networkId,
|
|
517
494
|
intentId,
|
|
518
495
|
operationMode: 'create',
|
|
519
496
|
skipEvaluation: true,
|
|
520
|
-
});
|
|
497
|
+
}));
|
|
521
498
|
const _createIntentIndexGraphMs = Date.now() - _createIntentIndexGraphStart;
|
|
522
|
-
_createIntentIndexTraceEmitter?.({ type: "graph_end", name: "intent_network", durationMs: _createIntentIndexGraphMs });
|
|
523
499
|
if (result.mutationResult) {
|
|
524
500
|
if (result.mutationResult.success) {
|
|
525
501
|
const alreadyExisted = result.mutationResult.message?.includes('already in this network') ?? false;
|
|
@@ -582,17 +558,14 @@ export function createIntentTools(defineTool, deps) {
|
|
|
582
558
|
}
|
|
583
559
|
}
|
|
584
560
|
const _readIntentIndexGraphStart = Date.now();
|
|
585
|
-
const
|
|
586
|
-
_readIntentIndexTraceEmitter?.({ type: "graph_start", name: "intent_network" });
|
|
587
|
-
const result = await invokeWithAbortSignal(graphs.intentIndex, {
|
|
561
|
+
const result = await traceGraph("intent_network", () => invokeWithAbortSignal(graphs.intentIndex, {
|
|
588
562
|
userId: context.userId,
|
|
589
563
|
networkId,
|
|
590
564
|
intentId,
|
|
591
565
|
operationMode: 'read',
|
|
592
566
|
queryUserId,
|
|
593
|
-
});
|
|
567
|
+
}));
|
|
594
568
|
const _readIntentIndexGraphMs = Date.now() - _readIntentIndexGraphStart;
|
|
595
|
-
_readIntentIndexTraceEmitter?.({ type: "graph_end", name: "intent_network", durationMs: _readIntentIndexGraphMs });
|
|
596
569
|
if (result.error) {
|
|
597
570
|
return error(result.error);
|
|
598
571
|
}
|
|
@@ -627,16 +600,13 @@ export function createIntentTools(defineTool, deps) {
|
|
|
627
600
|
return error(`This chat is scoped to ${context.indexName ?? 'this index'}. You can only unlink intents from this community.`);
|
|
628
601
|
}
|
|
629
602
|
const _deleteIntentIndexGraphStart = Date.now();
|
|
630
|
-
const
|
|
631
|
-
_deleteIntentIndexTraceEmitter?.({ type: "graph_start", name: "intent_network" });
|
|
632
|
-
const result = await invokeWithAbortSignal(graphs.intentIndex, {
|
|
603
|
+
const result = await traceGraph("intent_network", () => invokeWithAbortSignal(graphs.intentIndex, {
|
|
633
604
|
userId: context.userId,
|
|
634
605
|
networkId,
|
|
635
606
|
intentId,
|
|
636
607
|
operationMode: 'delete',
|
|
637
|
-
});
|
|
608
|
+
}));
|
|
638
609
|
const _deleteIntentIndexGraphMs = Date.now() - _deleteIntentIndexGraphStart;
|
|
639
|
-
_deleteIntentIndexTraceEmitter?.({ type: "graph_end", name: "intent_network", durationMs: _deleteIntentIndexGraphMs });
|
|
640
610
|
if (result.mutationResult) {
|
|
641
611
|
if (result.mutationResult.success) {
|
|
642
612
|
return success({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent.tools.js","sourceRoot":"/","sources":["intent/intent.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAG5E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAElD;;;GAGG;AACH,SAAS,wBAAwB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,wHAAwH;AACxH,KAAK,UAAU,sBAAsB,CACnC,OAAmE,EACnE,QAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACnF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,0BAA0B,OAAO,CAAC,SAAS,IAAI,YAAY,iDAAiD,CAAC;IACtH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,4BAA4B,CAAC,IAAmC;IACvE,MAAM,GAAG,GAAG,IA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CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACvG,OAAO,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,CAAU,CAAC;AAClJ,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport type { ExecutionResult, VerifiedIntent } from \"./intent.state.js\";\nimport { DEFAULT_SPECIFICITY_WARNING } from \"./intent.specificity.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { requestContext } from \"../shared/observability/request-context.js\";\n\nimport type { DefineTool, ToolDeps } from \"../shared/agent/tool.helpers.js\";\nimport { success, error, UUID_REGEX } from \"../shared/agent/tool.helpers.js\";\nimport type { UserRecord } from \"../shared/interfaces/database.interface.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"ChatTools:Intent\");\n\n/**\n * Sanitize JSON string for use inside a markdown code fence (```). Escapes backticks\n * so embedded ``` cannot close the fence prematurely.\n */\nfunction sanitizeJsonForCodeFence(json: string): string {\n return json.replace(/`/g, \"\\\\u0060\");\n}\n\n/** When context is index-scoped, verifies the caller is still a member of that index. Returns error message or null. */\nasync function ensureScopedMembership(\n context: { networkId?: string; indexName?: string; userId: string },\n systemDb: ToolDeps['systemDb']\n): Promise<string | null> {\n if (!context.networkId) return null;\n const isMember = await systemDb.isNetworkMember(context.networkId, context.userId);\n if (!isMember) {\n return `This chat is scoped to ${context.indexName ?? 'this index'}. You are no longer a member of this community.`;\n }\n return null;\n}\n\nfunction buildApprovedProfileFallback(user: UserRecord | null | undefined): string {\n const bio = user?.intro?.trim();\n if (!user || !bio) return \"\";\n\n return JSON.stringify({\n userId: user.id,\n identity: {\n name: user.name ?? \"\",\n bio,\n location: user.location?.trim() ?? \"\",\n },\n narrative: { context: bio },\n attributes: { skills: [], interests: [] },\n });\n}\n\nfunction isBroadAttributiveIntent(intent: VerifiedIntent): boolean {\n return intent.verification?.referential_breadth === \"broad\";\n}\n\nconst NULL_LIKE_SPECIFICITY_WARNING_VALUES = new Set([\"null\", \"undefined\"]);\n\nfunction normalizeSpecificityWarning(value: string | null | undefined): string | null {\n const warning = value?.trim();\n if (!warning) return null;\n return NULL_LIKE_SPECIFICITY_WARNING_VALUES.has(warning.toLowerCase()) ? null : warning;\n}\n\nfunction specificityWarningFor(intent: VerifiedIntent): string {\n return normalizeSpecificityWarning(intent.verification?.specificity_warning) ?? DEFAULT_SPECIFICITY_WARNING;\n}\n\nexport function createIntentTools(defineTool: DefineTool, deps: ToolDeps) {\n const { graphs, userDb } = deps;\n\n // ─────────────────────────────────────────────────────────────────────────────\n // INTENT CRUD\n // ─────────────────────────────────────────────────────────────────────────────\n\n const readIntents = defineTool({\n name: \"read_intents\",\n description:\n \"Retrieves intents (signals of interest/need, e.g. 'Looking for a React developer in Berlin'). \" +\n \"Intents are the core unit of discovery — they represent what users are seeking and drive semantic matching for opportunities.\\n\\n\" +\n \"**Usage modes:**\\n\" +\n \"- No parameters: returns the **caller's own** active intents. In an index-scoped chat the result is clamped to the reachable indexes (the bound index plus the user's personal index). In an unscoped chat the result spans all of the user's active intents. There is no implicit default to the scoped index — to browse the bound community's intents, pass `networkId` explicitly.\\n\" +\n \"- With networkId: returns **all members'** intents in that index (community browse path). Add userId to filter to one member.\\n\" +\n \"- With userId in an index-scoped chat: reads that member's intents in the bound index. The target user must be a member of that index.\\n\" +\n \"- With userId in an unscoped chat: only works for the current user (cannot read another user's global intents without an index scope).\\n\\n\" +\n \"**Workflow:** To explore what members of an index are looking for, first call read_network_memberships(networkId) to list members, \" +\n \"then read_intents(networkId) to see all intents in that community. \" +\n \"Each intent includes: id, description (payload), summary, confidence (0-1), inferenceType (explicit/implicit), status, and linked indexes.\\n\\n\" +\n \"**Returns:** Paginated list of intents with count. Use the intent IDs in subsequent calls to update_intent, delete_intent, or create_intent_index.\",\n querySchema: z.object({\n networkId: z.string().optional().describe(\"Index UUID — filters intents to this index (community browse path: returns all members' intents). There is no implicit default in index-scoped chats; omit to get caller-owned intents across the reachable indexes, or pass the scoped index UUID to browse community members. Get index IDs from read_networks.\"),\n userId: z.string().optional().describe(\"User ID — filters to this user's intents. In an index-scoped chat, this reads that member's intents in the bound index (no networkId required). In an unscoped chat, only the current user is allowed without networkId; cross-user reads require an index scope. Omit for caller-owned intents.\"),\n limit: z.number().int().min(1).max(100).optional().describe(\"Page size (1-100). Defaults to returning all results if omitted.\"),\n page: z.number().int().min(1).optional().describe(\"Page number (1-based). Only used when limit is also provided.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n\n // Distinguish \"explicit network browse\" from \"implicit scope-aware read\"\n const explicitNetworkId = query.networkId?.trim();\n const explicitUserId = query.userId?.trim();\n\n // Validate explicit networkId format\n if (explicitNetworkId && !UUID_REGEX.test(explicitNetworkId)) {\n return error(\"Invalid network ID format.\");\n }\n\n // Strict scope enforcement: in a scoped chat, the only allowed explicit\n // networkId is context.networkId itself. The chat's focus is the bound\n // network; cross-network browse must happen in a separate (unscoped)\n // chat or a chat scoped to that other network.\n if (context.networkId && explicitNetworkId && explicitNetworkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only read intents from this community.`\n );\n }\n\n // Cross-user read in scoped chat: target user must be a member of the scoped index\n if (context.networkId && explicitUserId && explicitUserId !== context.userId) {\n const isInScopedIndex = await deps.systemDb.isNetworkMember(context.networkId, explicitUserId);\n if (!isInScopedIndex) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only read intents from members of this community.`\n );\n }\n }\n\n // Cross-user global read is disallowed without an index scope\n if (!explicitNetworkId && !context.networkId && explicitUserId && explicitUserId !== context.userId) {\n return error(\"Cannot read another user's global intents. Use networkId to scope to a shared network.\");\n }\n\n // Membership check for explicit cross-network reads in unscoped chats\n if (!context.networkId && explicitNetworkId) {\n const callerIsMember = await deps.systemDb.isNetworkMember(explicitNetworkId, context.userId);\n if (!callerIsMember) {\n return error(\"You can only read intents from indexes you are a member of.\");\n }\n }\n\n // ── Choose the read mode ──\n // 1. Explicit networkId (browse all members in that index) — pass networkId, optionally + queryUserId.\n // 2. Explicit userId in a scoped chat — read that user's intents in the bound network.\n // 3. Explicit userId in an unscoped chat — only self (cross-user rejected above); global \"my intents\".\n // 4. Implicit (no explicit network/user) in scoped chat — pass indexScope, no networkId.\n // 5. Implicit in unscoped chat — global getActiveIntents (caller's own).\n const graphInput: Record<string, unknown> = {\n userId: context.userId,\n userProfile: \"\",\n operationMode: 'read' as const,\n };\n\n if (explicitNetworkId) {\n graphInput.networkId = explicitNetworkId;\n if (explicitUserId) graphInput.queryUserId = explicitUserId;\n } else if (explicitUserId && context.networkId) {\n // Scoped chat + userId: implicit network is the chat's bound network.\n // Membership of the target user was verified above.\n graphInput.networkId = context.networkId;\n graphInput.queryUserId = explicitUserId;\n } else if (explicitUserId) {\n // Unscoped chat + userId: only allowed for self (others rejected above).\n graphInput.queryUserId = explicitUserId;\n graphInput.allUserIntents = true;\n } else if (context.indexScope && context.indexScope.length > 0 && context.networkId) {\n // Scoped chat, implicit read: caller-only across reachable indexes.\n graphInput.indexScope = context.indexScope;\n } else {\n // Unscoped, implicit read: caller's global intents.\n graphInput.allUserIntents = true;\n }\n\n const _readIntentGraphStart = Date.now();\n const _readIntentTraceEmitter = requestContext.getStore()?.traceEmitter;\n _readIntentTraceEmitter?.({ type: \"graph_start\", name: \"intent\" });\n const result = await invokeWithAbortSignal(graphs.intent, graphInput);\n const _readIntentGraphMs = Date.now() - _readIntentGraphStart;\n _readIntentTraceEmitter?.({ type: \"graph_end\", name: \"intent\", durationMs: _readIntentGraphMs });\n\n if (result.readResult) {\n if (result.readResult.count === 0 && result.readResult.message && /not a member|Network not found/i.test(result.readResult.message)) {\n return error(result.readResult.message);\n }\n\n const shouldPaginate = query.limit !== undefined || query.page !== undefined;\n if (shouldPaginate && Array.isArray(result.readResult.intents)) {\n const limit = query.limit ?? 20;\n const page = query.page ?? 1;\n const offset = (page - 1) * limit;\n const pagedIntents = result.readResult.intents.slice(offset, offset + limit);\n return success({\n ...result.readResult,\n count: pagedIntents.length,\n totalCount: result.readResult.intents.length,\n limit,\n page,\n totalPages: Math.ceil(result.readResult.intents.length / limit),\n intents: pagedIntents,\n _graphTimings: [{ name: 'intent', durationMs: _readIntentGraphMs, agents: result.agentTimings ?? [] }],\n });\n }\n\n return success({ ...result.readResult, _graphTimings: [{ name: 'intent', durationMs: _readIntentGraphMs, agents: result.agentTimings ?? [] }] });\n }\n return error(\"Failed to fetch intents.\");\n },\n });\n\n const createIntent = defineTool({\n name: \"create_intent\",\n description:\n \"Creates a new intent (signal of interest/need) for the authenticated user. Intents drive the discovery engine — once created, \" +\n \"the system automatically evaluates them against indexes the user belongs to, links them to relevant communities, and begins \" +\n \"searching for matching opportunities (complementary intents from other users).\\n\\n\" +\n \"**What to pass:** A clear, concept-based description of what the user is looking for (e.g. 'Looking for an AI/ML co-founder in Berlin', \" +\n \"'Need a designer for a mobile app project'). If the user provided a URL, scrape it with scrape_url first and synthesize the content into a description.\\n\\n\" +\n \"**What happens:** The system runs inference (extracting structured intents), verification (checking specificity and speech-act type), \" +\n \"and returns a proposal widget. The proposal is NOT yet persisted — the user must approve it first.\\n\\n\" +\n \"**Returns:** An intent_proposal code block that MUST be included verbatim in the response. The frontend renders it as an interactive \" +\n \"card the user can approve or skip. On approval, the intent is persisted, indexed, and discovery begins.\\n\\n\" +\n \"**Next steps after approval:** The intent is automatically linked to relevant indexes. Call discover_opportunities(searchQuery) to explicitly trigger discovery, \" +\n \"or wait for background processing to find matches.\\n\\n\" +\n \"**Specificity gate.** Before calling this tool, judge whether the description is concrete enough to be \" +\n \"useful for matching. If the user says \\\"find a job\\\", \\\"meet people\\\", or \\\"learn something\\\", that's too \" +\n \"vague — FIRST call read_user_profiles() + read_intents() to understand their context, THEN propose a \" +\n \"refined version (\\\"Based on your background in X, did you mean 'Y'?\\\") and wait for confirmation before \" +\n \"calling create_intent. Specific asks (\\\"senior UX design role at a tech company in Berlin\\\") can go \" +\n \"directly to create_intent.\\n\\n\" +\n \"**URL handling.** If the user pastes a URL describing the intent (e.g. a job posting), call scrape_url \" +\n \"first with objective=\\\"Extract key details for an intent\\\", synthesize a conceptual description from the \" +\n \"content, then call create_intent with the synthesis. Exception: profile URLs (LinkedIn, GitHub, X) passed \" +\n \"to create_user_profile are handled by that tool directly — do not scrape first.\",\n querySchema: z.object({\n description: z.string().describe(\"A clear, specific description of what the user is looking for. Should be concept-based, not a raw URL. If the user shared a URL, scrape it first with scrape_url and pass the synthesized content here. Vague descriptions will be rejected — include what kind, what for, and/or timeframe.\"),\n networkId: z.string().optional().describe(\"Index UUID to link the intent to upon creation. Defaults to the scoped index in index-scoped chats. Get index IDs from read_networks. If omitted, the system auto-assigns to relevant indexes based on their prompts.\"),\n autoApprove: z.boolean().optional().describe(\"When true, automatically persists all verified intents without returning proposal cards for manual approval. MCP agents SHOULD set this to true since there is no UI for card-based approval. Web chat agents should omit or set to false to get interactive proposal cards.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n if (!query.description?.trim()) {\n return error(\"Description is required.\");\n }\n\n // Strict scope enforcement\n if (context.networkId && query.networkId?.trim() && query.networkId.trim() !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only create intents in this community.`\n );\n }\n\n const effectiveIndexId = context.networkId || query.networkId?.trim() || undefined;\n\n // Fetch profile (the intent graph needs it for inference)\n const _profileGraphStart1 = Date.now();\n const _createIntentProfileTraceEmitter = requestContext.getStore()?.traceEmitter;\n _createIntentProfileTraceEmitter?.({ type: \"graph_start\", name: \"profile\" });\n const profileResult = await invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' as const });\n const _profileGraphMs1 = Date.now() - _profileGraphStart1;\n _createIntentProfileTraceEmitter?.({ type: \"graph_end\", name: \"profile\", durationMs: _profileGraphMs1 });\n const latestUser = profileResult.profile ? undefined : typeof userDb.getUser === \"function\" ? await userDb.getUser() : context.user;\n const approvedProfileFallback = profileResult.profile ? \"\" : buildApprovedProfileFallback(latestUser);\n const userProfile = profileResult.profile ? JSON.stringify(profileResult.profile) : approvedProfileFallback;\n\n // Run inference + verification only (propose mode — no DB persistence)\n const _intentGraphStart1 = Date.now();\n const _createIntentTraceEmitter = requestContext.getStore()?.traceEmitter;\n _createIntentTraceEmitter?.({ type: \"graph_start\", name: \"intent\" });\n const result = await invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile,\n inputContent: query.description,\n operationMode: 'propose' as const,\n ...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),\n });\n const _intentGraphMs1 = Date.now() - _intentGraphStart1;\n _createIntentTraceEmitter?.({ type: \"graph_end\", name: \"intent\", durationMs: _intentGraphMs1 });\n logger.debug(\"Intent graph propose response\", { result });\n\n const verified = result.verifiedIntents || [];\n\n // MCP contexts have no interactive UI for proposal cards — default to auto-approve\n const shouldAutoApprove = query.autoApprove ?? context.isMcp ?? false;\n \n // Extract trace from graph and convert to debugSteps\n const trace = Array.isArray(result.trace) ? result.trace : [];\n const debugSteps = trace.map((t: { node: string; detail?: string; data?: Record<string, unknown> }) => ({\n step: t.node,\n detail: t.detail,\n ...(t.data ? { data: t.data } : {}),\n }));\n \n if (verified.length === 0) {\n // Build a descriptive rejection reason from the trace so the ReACT agent\n // can retry with a better description or ask the user for clarification.\n // When inference produces 0 intents, propose mode exits before verification\n // runs — so we check inference trace first.\n const verificationTrace = debugSteps.find((s: { step: string; detail?: string }) => s.step === \"verification\");\n\n if (!verificationTrace) {\n const inferenceHint =\n debugSteps.find((s: { step: string; detail?: string }) => s.step === \"inference\")?.detail\n ?? \"no intents extracted\";\n return error(\n `No actionable intent was extracted (${inferenceHint}). ` +\n `Please retry with a more specific goal (what kind, what for, and/or timeframe), ` +\n `or ask the user to clarify.`,\n debugSteps,\n );\n }\n\n const rejectionHint =\n verificationTrace.detail ?? \"all candidate intents were filtered as invalid or too vague\";\n return error(\n `Intent verification failed (${rejectionHint}). ` +\n `The description may be too vague or was classified as a statement rather than a goal. ` +\n `Either retry with a more specific description (e.g. include what kind, what for, or a timeframe) ` +\n `or ask the user to clarify what exactly they are looking for.`,\n debugSteps,\n );\n }\n\n // ── Auto-approve path (for MCP agents or explicit opt-in) ──\n if (shouldAutoApprove) {\n const broadIntents = (verified as VerifiedIntent[]).filter(isBroadAttributiveIntent);\n if (broadIntents.length > 0) {\n const first = broadIntents[0];\n const missing = first.verification?.missing_selectional_constraints ?? [];\n const missingHint = missing.length > 0\n ? ` Missing specifics: ${missing.map((m) => m.replace(/_/g, \" \")).join(\", \")}.`\n : \"\";\n return error(\n `${specificityWarningFor(first)}${missingHint} ` +\n `Please ask the user to clarify before creating this signal, or retry with a narrower description.`,\n debugSteps,\n );\n }\n\n const createdIntents: Array<{ description: string; confidence: number | null; speechActType: string | null }> = [];\n const createTimings: Array<{ name: string; durationMs: number; agents: unknown[] }> = [];\n\n for (const v of verified as VerifiedIntent[]) {\n const _createGraphStart = Date.now();\n const _createTraceEmitter = requestContext.getStore()?.traceEmitter;\n _createTraceEmitter?.({ type: \"graph_start\", name: \"intent\" });\n const createResult = await invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile,\n inputContent: v.description,\n operationMode: 'create' as const,\n ...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),\n });\n const _createGraphMs = Date.now() - _createGraphStart;\n _createTraceEmitter?.({ type: \"graph_end\", name: \"intent\", durationMs: _createGraphMs });\n\n createTimings.push({ name: 'intent-create', durationMs: _createGraphMs, agents: createResult.agentTimings ?? [] });\n\n const succeeded = createResult.executionResults?.some((r: ExecutionResult) => r.success);\n if (succeeded) {\n createdIntents.push({\n description: v.description,\n confidence: v.score != null ? Math.round(v.score * 100) / 100 : null,\n speechActType: v.verification?.classification ?? null,\n });\n }\n }\n\n return success({\n created: createdIntents.length > 0,\n count: createdIntents.length,\n intents: createdIntents,\n message: createdIntents.length > 0\n ? `Created ${createdIntents.length} intent${createdIntents.length > 1 ? 's' : ''} successfully. The system will automatically index them and begin searching for matching opportunities.`\n : 'Intent creation failed — the intents could not be persisted.',\n debugSteps,\n _graphTimings: [\n { name: 'profile', durationMs: _profileGraphMs1, agents: profileResult.agentTimings ?? [] },\n { name: 'intent-propose', durationMs: _intentGraphMs1, agents: result.agentTimings ?? [] },\n ...createTimings,\n ],\n });\n }\n\n // ── Proposal path (for web chat with interactive cards) ──\n // Build intent_proposal code fences for each verified intent\n const proposalBlocks = verified.map((v: VerifiedIntent) => {\n const proposalId = crypto.randomUUID();\n const isBroad = isBroadAttributiveIntent(v);\n const data = {\n proposalId,\n description: v.description,\n ...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),\n confidence: v.score != null ? Math.round(v.score * 100) / 100 : null,\n speechActType: v.verification?.classification ?? null,\n semanticEntropy: v.verification?.semantic_entropy ?? null,\n referentialBreadth: v.verification?.referential_breadth ?? null,\n missingSelectionalConstraints: v.verification?.missing_selectional_constraints ?? [],\n specificityWarning: isBroad ? specificityWarningFor(v) : normalizeSpecificityWarning(v.verification?.specificity_warning),\n };\n return (\n \"```intent_proposal\\n\" +\n sanitizeJsonForCodeFence(JSON.stringify(data)) +\n \"\\n```\"\n );\n });\n\n const blocksText = proposalBlocks.join(\"\\n\\n\");\n\n return success({\n proposed: true,\n count: verified.length,\n message: `IMPORTANT: Include the following \\`\\`\\`intent_proposal code blocks EXACTLY as-is in your response (they render as interactive cards for the user to approve or skip):\\n\\n${blocksText}`,\n debugSteps,\n _graphTimings: [\n { name: 'profile', durationMs: _profileGraphMs1, agents: profileResult.agentTimings ?? [] },\n { name: 'intent', durationMs: _intentGraphMs1, agents: result.agentTimings ?? [] },\n ],\n });\n },\n });\n\n const updateIntent = defineTool({\n name: \"update_intent\",\n description:\n \"Updates an existing intent's description. After updating, the system re-processes the intent through inference and verification, \" +\n \"re-evaluates its index assignments, and triggers fresh opportunity discovery with the new description.\\n\\n\" +\n \"**When to use:** When the user wants to refine or change what they're looking for — e.g. narrowing scope, adding specificity, \" +\n \"or pivoting to a different need. Prefer updating over delete+create to preserve the intent's history and existing index links.\\n\\n\" +\n \"**Returns:** Updated `intentId` and `description`, plus a confirmation message. The intent's embeddings and index relevancy scores are recalculated automatically.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to update. Get this from read_intents results.\"),\n description: z.string().describe(\"The updated description of what the user is looking for. Same guidelines as create_intent — should be clear and specific.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n if (!UUID_REGEX.test(intentId)) {\n return error(\"Invalid intent ID format.\");\n }\n\n // Ownership guard: caller must own the intent\n const intent = await deps.systemDb.getIntent(intentId);\n if (!intent || intent.userId !== context.userId) {\n return error(\"Intent not found or you can only update your own intents.\");\n }\n if (intent.archivedAt) {\n return error(\"This intent is archived and cannot be updated. Create a new intent instead.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, verify intent is linked to that index\n if (context.networkId) {\n const db = deps.userDb;\n const intentNetworks = await db.getNetworkIdsForIntent(intentId);\n if (!intentNetworks.includes(context.networkId)) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only update intents linked to this community.`\n );\n }\n }\n\n const _profileGraphStart2 = Date.now();\n const _updateIntentProfileTraceEmitter = requestContext.getStore()?.traceEmitter;\n _updateIntentProfileTraceEmitter?.({ type: \"graph_start\", name: \"profile\" });\n const profileResult = await invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' as const });\n const _profileGraphMs2 = Date.now() - _profileGraphStart2;\n _updateIntentProfileTraceEmitter?.({ type: \"graph_end\", name: \"profile\", durationMs: _profileGraphMs2 });\n const latestUser = profileResult.profile ? undefined : typeof userDb.getUser === \"function\" ? await userDb.getUser() : context.user;\n const approvedProfileFallback = profileResult.profile ? \"\" : buildApprovedProfileFallback(latestUser);\n const userProfile = profileResult.profile ? JSON.stringify(profileResult.profile) : approvedProfileFallback;\n\n const _intentGraphStart2 = Date.now();\n const _updateIntentTraceEmitter = requestContext.getStore()?.traceEmitter;\n _updateIntentTraceEmitter?.({ type: \"graph_start\", name: \"intent\" });\n const result = await invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile,\n operationMode: 'update' as const,\n inputContent: query.description,\n targetIntentIds: [intentId],\n ...(context.networkId && { networkId: context.networkId }),\n });\n const _intentGraphMs2 = Date.now() - _intentGraphStart2;\n _updateIntentTraceEmitter?.({ type: \"graph_end\", name: \"intent\", durationMs: _intentGraphMs2 });\n\n if (result.executionResults?.some((r: ExecutionResult) => !r.success)) {\n return error(\"Failed to update intent.\");\n }\n if (!result.executionResults?.some((r: ExecutionResult) => r.success)) {\n return error(\n \"Intent update was not applied. The new description may be too broad, too vague, or failed semantic verification. Please ask the user to clarify with a more concrete role, outcome, location, timeframe, domain, or specific need.\",\n );\n }\n return success({\n message: \"Intent updated.\",\n intentId,\n description: query.description,\n _graphTimings: [\n { name: 'profile', durationMs: _profileGraphMs2, agents: profileResult.agentTimings ?? [] },\n { name: 'intent', durationMs: _intentGraphMs2, agents: result.agentTimings ?? [] },\n ],\n });\n },\n });\n\n const deleteIntent = defineTool({\n name: \"delete_intent\",\n description:\n \"Archives (soft-deletes) an intent, removing it from active discovery. The intent is not permanently deleted — it is marked as archived \" +\n \"and no longer participates in opportunity matching or index evaluation.\\n\\n\" +\n \"**When to use:** When the user's need has been fulfilled, is no longer relevant, or was created by mistake. \" +\n \"If the user wants to change the description instead, use update_intent to preserve history.\\n\\n\" +\n \"**Returns:** Confirmation that the intent was archived. Previously created opportunities from this intent remain but won't generate new ones.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to archive. Get this from read_intents results.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n if (!UUID_REGEX.test(intentId)) {\n return error(\"Invalid intent ID format.\");\n }\n\n // Ownership guard: caller must own the intent\n const intent = await deps.systemDb.getIntent(intentId);\n if (!intent || intent.userId !== context.userId) {\n return error(\"Intent not found or you can only delete your own intents.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, verify intent is linked to that index\n if (context.networkId) {\n const db = deps.userDb;\n const intentNetworks = await db.getNetworkIdsForIntent(intentId);\n if (!intentNetworks.includes(context.networkId)) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only delete intents linked to this community.`\n );\n }\n }\n\n const _deleteIntentGraphStart = Date.now();\n const _deleteIntentTraceEmitter = requestContext.getStore()?.traceEmitter;\n _deleteIntentTraceEmitter?.({ type: \"graph_start\", name: \"intent\" });\n const result = await invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile: \"\",\n operationMode: 'delete' as const,\n targetIntentIds: [intentId],\n ...(context.networkId && { networkId: context.networkId }),\n });\n const _deleteIntentGraphMs = Date.now() - _deleteIntentGraphStart;\n _deleteIntentTraceEmitter?.({ type: \"graph_end\", name: \"intent\", durationMs: _deleteIntentGraphMs });\n\n if (result.executionResults?.some((r: ExecutionResult) => !r.success)) {\n return error(\"Failed to delete intent.\");\n }\n return success({\n message: \"Intent archived successfully.\",\n _graphTimings: [{ name: 'intent', durationMs: _deleteIntentGraphMs, agents: result.agentTimings ?? [] }],\n });\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────────\n // INTENT–INDEX JUNCTION (link / list / unlink)\n // ─────────────────────────────────────────────────────────────────────────────\n\n const createIntentIndex = defineTool({\n name: \"create_intent_index\",\n description:\n \"Manually links an intent to an index (community), making it visible to other members and eligible for opportunity discovery within that index. \" +\n \"Normally intents are auto-assigned to relevant indexes on creation, but use this to explicitly add an intent to an additional index.\\n\\n\" +\n \"**When to use:** When the user wants to share an existing intent with a specific community they belong to, \" +\n \"or when auto-assignment missed an index the user considers relevant.\\n\\n\" +\n \"**Returns:** Confirmation that the link was created. The intent will now appear in that index's intent list and participate in discovery within that community.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to link. Get this from read_intents results.\"),\n networkId: z.string().optional().describe(\"The UUID of the index to link the intent to. Get this from read_networks. Defaults to the scoped index in index-scoped chats.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n const networkId = query.networkId?.trim() || context.networkId || \"\";\n if (!UUID_REGEX.test(intentId) || !UUID_REGEX.test(networkId)) {\n return error(\"Invalid ID format. Both must be UUIDs.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, only allow linking to that index\n if (context.networkId && networkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only link intents to this community.`\n );\n }\n\n const _createIntentIndexGraphStart = Date.now();\n const _createIntentIndexTraceEmitter = requestContext.getStore()?.traceEmitter;\n _createIntentIndexTraceEmitter?.({ type: \"graph_start\", name: \"intent_network\" });\n const result = await invokeWithAbortSignal(graphs.intentIndex, {\n userId: context.userId,\n networkId,\n intentId,\n operationMode: 'create' as const,\n skipEvaluation: true,\n });\n const _createIntentIndexGraphMs = Date.now() - _createIntentIndexGraphStart;\n _createIntentIndexTraceEmitter?.({ type: \"graph_end\", name: \"intent_network\", durationMs: _createIntentIndexGraphMs });\n\n if (result.mutationResult) {\n if (result.mutationResult.success) {\n const alreadyExisted = result.mutationResult.message?.includes('already in this network') ?? false;\n return success({\n created: !alreadyExisted,\n message: result.mutationResult.message,\n _graphTimings: [{ name: 'intent_network', durationMs: _createIntentIndexGraphMs, agents: result.agentTimings ?? [] }],\n });\n }\n return error(result.mutationResult.error || \"Failed to link intent to network.\");\n }\n return error(\"Failed to link intent to network.\");\n },\n });\n\n const readIntentIndexes = defineTool({\n name: \"read_intent_indexes\",\n description:\n \"Reads the many-to-many links between intents and indexes. Use this to understand which intents are shared in which communities, \" +\n \"and which indexes a specific intent belongs to.\\n\\n\" +\n \"**Usage modes:**\\n\" +\n \"- With networkId: lists all intents linked to that index. Add userId to filter to one member's intents in that index.\\n\" +\n \"- With intentId + networkId: checks whether a specific intent is linked to a specific index.\\n\" +\n \"- intentId alone requires a networkId (the system won't reveal all indexes an intent is in).\\n\\n\" +\n \"**When to use:** To audit which intents are active in a community, verify an intent's index assignment before unlinking, \" +\n \"or check if a newly created intent was auto-assigned to the expected index.\\n\\n\" +\n \"**Returns:** List of intent-index links with relevancy scores (0-1, how well the intent fits the index's purpose).\",\n querySchema: z.object({\n intentId: z.string().optional().describe(\"Intent UUID — check if this specific intent is linked to the specified index. Must be combined with networkId.\"),\n networkId: z.string().optional().describe(\"Index UUID — list all intents linked to this index. Get this from read_networks. Defaults to scoped index in index-scoped chats.\"),\n userId: z.string().optional().describe(\"Filter results to this user's intents within the specified index. Omit to see all members' intents.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() || undefined;\n let networkId = query.networkId?.trim() || context.networkId || undefined;\n const queryUserId = query.userId?.trim() || undefined;\n\n if (intentId && !UUID_REGEX.test(intentId)) {\n return error(\"Invalid intent ID format.\");\n }\n if (networkId && !UUID_REGEX.test(networkId)) {\n return error(\"Invalid network ID format.\");\n }\n if (!intentId && !networkId) {\n return error(\"Provide networkId or intentId.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, only allow querying that index\n if (context.networkId && networkId && networkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only read intent links from this community.`\n );\n }\n\n // When only intentId is provided, enforce scope - don't reveal all linked indexes\n if (intentId && !networkId) {\n if (context.networkId) {\n // When scoped, only check if intent is linked to the scoped index\n networkId = context.networkId;\n } else {\n // When unscoped, still don't reveal all indexes - require explicit networkId\n return error(\n \"Please provide a networkId to check if the intent is linked to a specific network. Listing all linked networks is not supported.\"\n );\n }\n }\n\n const _readIntentIndexGraphStart = Date.now();\n const _readIntentIndexTraceEmitter = requestContext.getStore()?.traceEmitter;\n _readIntentIndexTraceEmitter?.({ type: \"graph_start\", name: \"intent_network\" });\n const result = await invokeWithAbortSignal(graphs.intentIndex, {\n userId: context.userId,\n networkId,\n intentId,\n operationMode: 'read' as const,\n queryUserId,\n });\n const _readIntentIndexGraphMs = Date.now() - _readIntentIndexGraphStart;\n _readIntentIndexTraceEmitter?.({ type: \"graph_end\", name: \"intent_network\", durationMs: _readIntentIndexGraphMs });\n\n if (result.error) {\n return error(result.error);\n }\n if (result.readResult) {\n return success({ ...result.readResult, _graphTimings: [{ name: 'intent_network', durationMs: _readIntentIndexGraphMs, agents: result.agentTimings ?? [] }] });\n }\n return error(\"Failed to fetch intent-network links.\");\n },\n });\n\n const deleteIntentIndex = defineTool({\n name: \"delete_intent_index\",\n description:\n \"Removes the link between an intent and an index. The intent itself is NOT deleted — it just stops being visible in that community \" +\n \"and no longer participates in opportunity discovery within that index. The intent may still be linked to other indexes.\\n\\n\" +\n \"**When to use:** When the user wants to withdraw an intent from a specific community without archiving it entirely. \" +\n \"Use read_intent_indexes first to verify the link exists.\\n\\n\" +\n \"**Returns:** Confirmation that the link was removed. To fully remove an intent, use delete_intent instead.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to unlink. Get this from read_intents or read_intent_indexes.\"),\n networkId: z.string().optional().describe(\"The UUID of the index to unlink from. Get this from read_networks. Defaults to the scoped index in index-scoped chats.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n const networkId = query.networkId?.trim() || context.networkId || \"\";\n if (!UUID_REGEX.test(intentId) || !UUID_REGEX.test(networkId)) {\n return error(\"Invalid ID format. Both must be UUIDs.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, only allow unlinking from that index\n if (context.networkId && networkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only unlink intents from this community.`\n );\n }\n\n const _deleteIntentIndexGraphStart = Date.now();\n const _deleteIntentIndexTraceEmitter = requestContext.getStore()?.traceEmitter;\n _deleteIntentIndexTraceEmitter?.({ type: \"graph_start\", name: \"intent_network\" });\n const result = await invokeWithAbortSignal(graphs.intentIndex, {\n userId: context.userId,\n networkId,\n intentId,\n operationMode: 'delete' as const,\n });\n const _deleteIntentIndexGraphMs = Date.now() - _deleteIntentIndexGraphStart;\n _deleteIntentIndexTraceEmitter?.({ type: \"graph_end\", name: \"intent_network\", durationMs: _deleteIntentIndexGraphMs });\n\n if (result.mutationResult) {\n if (result.mutationResult.success) {\n return success({\n deleted: true,\n message: result.mutationResult.message,\n _graphTimings: [{ name: 'intent_network', durationMs: _deleteIntentIndexGraphMs, agents: result.agentTimings ?? [] }],\n });\n }\n return error(result.mutationResult.error || \"Failed to unlink.\");\n }\n return error(\"Failed to unlink intent from network.\");\n },\n });\n\n const searchIntents = defineTool({\n name: \"search_intents\",\n description:\n \"Text-searches the authenticated user's own active signals by description. Case-insensitive substring \" +\n \"match over the signal's payload and summary. Use when the user references a past signal they wrote \" +\n '(\"find my signal about React mentorship\") or wants to audit what they\\'ve posted.\\n\\n' +\n \"For discovery of OTHER users' signals that match a query, use discover_opportunities(searchQuery=...) \" +\n \"instead — that runs semantic matching across the user's networks.\\n\\n\" +\n \"**Returns:** `intents: [{ id, payload, summary, createdAt }]`, most recent first, up to `limit` (default 25).\",\n querySchema: z.object({\n query: z.string().min(1).describe(\"Text to match against payload and summary (case-insensitive).\"),\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .describe(\"Maximum intents to return (default 25, max 100).\"),\n }),\n handler: async ({ context, query }) => {\n const rows = await userDb.searchOwnIntents(query.query, query.limit ?? 25);\n logger.verbose(\"search_intents\", { userId: context.userId, query: query.query, matched: rows.length });\n return success({ intents: rows });\n },\n });\n\n return [readIntents, createIntent, updateIntent, deleteIntent, createIntentIndex, readIntentIndexes, deleteIntentIndex, searchIntents] as const;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"intent.tools.js","sourceRoot":"/","sources":["intent/intent.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAElD;;;GAGG;AACH,SAAS,wBAAwB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,wHAAwH;AACxH,KAAK,UAAU,sBAAsB,CACnC,OAAmE,EACnE,QAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACnF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,0BAA0B,OAAO,CAAC,SAAS,IAAI,YAAY,iDAAiD,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,KAAK,EAAE,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC3E,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACvG,OAAO,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,CAAU,CAAC;AAClJ,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport type { ExecutionResult, VerifiedIntent } from \"./intent.state.js\";\nimport { DEFAULT_SPECIFICITY_WARNING } from \"./intent.specificity.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { traceGraph } from \"../shared/observability/trace.js\";\n\nimport type { DefineTool, ToolDeps } from \"../shared/agent/tool.helpers.js\";\nimport { success, error, UUID_REGEX } from \"../shared/agent/tool.helpers.js\";\nimport type { UserRecord } from \"../shared/interfaces/database.interface.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"ChatTools:Intent\");\n\n/**\n * Sanitize JSON string for use inside a markdown code fence (```). Escapes backticks\n * so embedded ``` cannot close the fence prematurely.\n */\nfunction sanitizeJsonForCodeFence(json: string): string {\n return json.replace(/`/g, \"\\\\u0060\");\n}\n\n/** When context is index-scoped, verifies the caller is still a member of that index. Returns error message or null. */\nasync function ensureScopedMembership(\n context: { networkId?: string; indexName?: string; userId: string },\n systemDb: ToolDeps['systemDb']\n): Promise<string | null> {\n if (!context.networkId) return null;\n const isMember = await systemDb.isNetworkMember(context.networkId, context.userId);\n if (!isMember) {\n return `This chat is scoped to ${context.indexName ?? 'this index'}. You are no longer a member of this community.`;\n }\n return null;\n}\n\nfunction buildApprovedProfileFallback(user: UserRecord | null | undefined): string {\n const bio = user?.intro?.trim();\n if (!user || !bio) return \"\";\n\n return JSON.stringify({\n userId: user.id,\n identity: {\n name: user.name ?? \"\",\n bio,\n location: user.location?.trim() ?? \"\",\n },\n narrative: { context: bio },\n attributes: { skills: [], interests: [] },\n });\n}\n\nfunction isBroadAttributiveIntent(intent: VerifiedIntent): boolean {\n return intent.verification?.referential_breadth === \"broad\";\n}\n\nconst NULL_LIKE_SPECIFICITY_WARNING_VALUES = new Set([\"null\", \"undefined\"]);\n\nfunction normalizeSpecificityWarning(value: string | null | undefined): string | null {\n const warning = value?.trim();\n if (!warning) return null;\n return NULL_LIKE_SPECIFICITY_WARNING_VALUES.has(warning.toLowerCase()) ? null : warning;\n}\n\nfunction specificityWarningFor(intent: VerifiedIntent): string {\n return normalizeSpecificityWarning(intent.verification?.specificity_warning) ?? DEFAULT_SPECIFICITY_WARNING;\n}\n\nexport function createIntentTools(defineTool: DefineTool, deps: ToolDeps) {\n const { graphs, userDb } = deps;\n\n // ─────────────────────────────────────────────────────────────────────────────\n // INTENT CRUD\n // ─────────────────────────────────────────────────────────────────────────────\n\n const readIntents = defineTool({\n name: \"read_intents\",\n description:\n \"Retrieves intents (signals of interest/need, e.g. 'Looking for a React developer in Berlin'). \" +\n \"Intents are the core unit of discovery — they represent what users are seeking and drive semantic matching for opportunities.\\n\\n\" +\n \"**Usage modes:**\\n\" +\n \"- No parameters: returns the **caller's own** active intents. In an index-scoped chat the result is clamped to the reachable indexes (the bound index plus the user's personal index). In an unscoped chat the result spans all of the user's active intents. There is no implicit default to the scoped index — to browse the bound community's intents, pass `networkId` explicitly.\\n\" +\n \"- With networkId: returns **all members'** intents in that index (community browse path). Add userId to filter to one member.\\n\" +\n \"- With userId in an index-scoped chat: reads that member's intents in the bound index. The target user must be a member of that index.\\n\" +\n \"- With userId in an unscoped chat: only works for the current user (cannot read another user's global intents without an index scope).\\n\\n\" +\n \"**Workflow:** To explore what members of an index are looking for, first call read_network_memberships(networkId) to list members, \" +\n \"then read_intents(networkId) to see all intents in that community. \" +\n \"Each intent includes: id, description (payload), summary, confidence (0-1), inferenceType (explicit/implicit), status, and linked indexes.\\n\\n\" +\n \"**Returns:** Paginated list of intents with count. Use the intent IDs in subsequent calls to update_intent, delete_intent, or create_intent_index.\",\n querySchema: z.object({\n networkId: z.string().optional().describe(\"Index UUID — filters intents to this index (community browse path: returns all members' intents). There is no implicit default in index-scoped chats; omit to get caller-owned intents across the reachable indexes, or pass the scoped index UUID to browse community members. Get index IDs from read_networks.\"),\n userId: z.string().optional().describe(\"User ID — filters to this user's intents. In an index-scoped chat, this reads that member's intents in the bound index (no networkId required). In an unscoped chat, only the current user is allowed without networkId; cross-user reads require an index scope. Omit for caller-owned intents.\"),\n limit: z.number().int().min(1).max(100).optional().describe(\"Page size (1-100). Defaults to returning all results if omitted.\"),\n page: z.number().int().min(1).optional().describe(\"Page number (1-based). Only used when limit is also provided.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n\n // Distinguish \"explicit network browse\" from \"implicit scope-aware read\"\n const explicitNetworkId = query.networkId?.trim();\n const explicitUserId = query.userId?.trim();\n\n // Validate explicit networkId format\n if (explicitNetworkId && !UUID_REGEX.test(explicitNetworkId)) {\n return error(\"Invalid network ID format.\");\n }\n\n // Strict scope enforcement: in a scoped chat, the only allowed explicit\n // networkId is context.networkId itself. The chat's focus is the bound\n // network; cross-network browse must happen in a separate (unscoped)\n // chat or a chat scoped to that other network.\n if (context.networkId && explicitNetworkId && explicitNetworkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only read intents from this community.`\n );\n }\n\n // Cross-user read in scoped chat: target user must be a member of the scoped index\n if (context.networkId && explicitUserId && explicitUserId !== context.userId) {\n const isInScopedIndex = await deps.systemDb.isNetworkMember(context.networkId, explicitUserId);\n if (!isInScopedIndex) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only read intents from members of this community.`\n );\n }\n }\n\n // Cross-user global read is disallowed without an index scope\n if (!explicitNetworkId && !context.networkId && explicitUserId && explicitUserId !== context.userId) {\n return error(\"Cannot read another user's global intents. Use networkId to scope to a shared network.\");\n }\n\n // Membership check for explicit cross-network reads in unscoped chats\n if (!context.networkId && explicitNetworkId) {\n const callerIsMember = await deps.systemDb.isNetworkMember(explicitNetworkId, context.userId);\n if (!callerIsMember) {\n return error(\"You can only read intents from indexes you are a member of.\");\n }\n }\n\n // ── Choose the read mode ──\n // 1. Explicit networkId (browse all members in that index) — pass networkId, optionally + queryUserId.\n // 2. Explicit userId in a scoped chat — read that user's intents in the bound network.\n // 3. Explicit userId in an unscoped chat — only self (cross-user rejected above); global \"my intents\".\n // 4. Implicit (no explicit network/user) in scoped chat — pass indexScope, no networkId.\n // 5. Implicit in unscoped chat — global getActiveIntents (caller's own).\n const graphInput: Record<string, unknown> = {\n userId: context.userId,\n userProfile: \"\",\n operationMode: 'read' as const,\n };\n\n if (explicitNetworkId) {\n graphInput.networkId = explicitNetworkId;\n if (explicitUserId) graphInput.queryUserId = explicitUserId;\n } else if (explicitUserId && context.networkId) {\n // Scoped chat + userId: implicit network is the chat's bound network.\n // Membership of the target user was verified above.\n graphInput.networkId = context.networkId;\n graphInput.queryUserId = explicitUserId;\n } else if (explicitUserId) {\n // Unscoped chat + userId: only allowed for self (others rejected above).\n graphInput.queryUserId = explicitUserId;\n graphInput.allUserIntents = true;\n } else if (context.indexScope && context.indexScope.length > 0 && context.networkId) {\n // Scoped chat, implicit read: caller-only across reachable indexes.\n graphInput.indexScope = context.indexScope;\n } else {\n // Unscoped, implicit read: caller's global intents.\n graphInput.allUserIntents = true;\n }\n\n const _readIntentGraphStart = Date.now();\n const result = await traceGraph(\"intent\", () => invokeWithAbortSignal(graphs.intent, graphInput));\n const _readIntentGraphMs = Date.now() - _readIntentGraphStart;\n\n if (result.readResult) {\n if (result.readResult.count === 0 && result.readResult.message && /not a member|Network not found/i.test(result.readResult.message)) {\n return error(result.readResult.message);\n }\n\n const shouldPaginate = query.limit !== undefined || query.page !== undefined;\n if (shouldPaginate && Array.isArray(result.readResult.intents)) {\n const limit = query.limit ?? 20;\n const page = query.page ?? 1;\n const offset = (page - 1) * limit;\n const pagedIntents = result.readResult.intents.slice(offset, offset + limit);\n return success({\n ...result.readResult,\n count: pagedIntents.length,\n totalCount: result.readResult.intents.length,\n limit,\n page,\n totalPages: Math.ceil(result.readResult.intents.length / limit),\n intents: pagedIntents,\n _graphTimings: [{ name: 'intent', durationMs: _readIntentGraphMs, agents: result.agentTimings ?? [] }],\n });\n }\n\n return success({ ...result.readResult, _graphTimings: [{ name: 'intent', durationMs: _readIntentGraphMs, agents: result.agentTimings ?? [] }] });\n }\n return error(\"Failed to fetch intents.\");\n },\n });\n\n const createIntent = defineTool({\n name: \"create_intent\",\n description:\n \"Creates a new intent (signal of interest/need) for the authenticated user. Intents drive the discovery engine — once created, \" +\n \"the system automatically evaluates them against indexes the user belongs to, links them to relevant communities, and begins \" +\n \"searching for matching opportunities (complementary intents from other users).\\n\\n\" +\n \"**What to pass:** A clear, concept-based description of what the user is looking for (e.g. 'Looking for an AI/ML co-founder in Berlin', \" +\n \"'Need a designer for a mobile app project'). If the user provided a URL, scrape it with scrape_url first and synthesize the content into a description.\\n\\n\" +\n \"**What happens:** The system runs inference (extracting structured intents), verification (checking specificity and speech-act type), \" +\n \"and returns a proposal widget. The proposal is NOT yet persisted — the user must approve it first.\\n\\n\" +\n \"**Returns:** An intent_proposal code block that MUST be included verbatim in the response. The frontend renders it as an interactive \" +\n \"card the user can approve or skip. On approval, the intent is persisted, indexed, and discovery begins.\\n\\n\" +\n \"**Next steps after approval:** The intent is automatically linked to relevant indexes. Call discover_opportunities(searchQuery) to explicitly trigger discovery, \" +\n \"or wait for background processing to find matches.\\n\\n\" +\n \"**Specificity gate.** Before calling this tool, judge whether the description is concrete enough to be \" +\n \"useful for matching. If the user says \\\"find a job\\\", \\\"meet people\\\", or \\\"learn something\\\", that's too \" +\n \"vague — FIRST call read_user_profiles() + read_intents() to understand their context, THEN propose a \" +\n \"refined version (\\\"Based on your background in X, did you mean 'Y'?\\\") and wait for confirmation before \" +\n \"calling create_intent. Specific asks (\\\"senior UX design role at a tech company in Berlin\\\") can go \" +\n \"directly to create_intent.\\n\\n\" +\n \"**URL handling.** If the user pastes a URL describing the intent (e.g. a job posting), call scrape_url \" +\n \"first with objective=\\\"Extract key details for an intent\\\", synthesize a conceptual description from the \" +\n \"content, then call create_intent with the synthesis. Exception: profile URLs (LinkedIn, GitHub, X) passed \" +\n \"to create_user_profile are handled by that tool directly — do not scrape first.\",\n querySchema: z.object({\n description: z.string().describe(\"A clear, specific description of what the user is looking for. Should be concept-based, not a raw URL. If the user shared a URL, scrape it first with scrape_url and pass the synthesized content here. Vague descriptions will be rejected — include what kind, what for, and/or timeframe.\"),\n networkId: z.string().optional().describe(\"Index UUID to link the intent to upon creation. Defaults to the scoped index in index-scoped chats. Get index IDs from read_networks. If omitted, the system auto-assigns to relevant indexes based on their prompts.\"),\n autoApprove: z.boolean().optional().describe(\"When true, automatically persists all verified intents without returning proposal cards for manual approval. MCP agents SHOULD set this to true since there is no UI for card-based approval. Web chat agents should omit or set to false to get interactive proposal cards.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n if (!query.description?.trim()) {\n return error(\"Description is required.\");\n }\n\n // Strict scope enforcement\n if (context.networkId && query.networkId?.trim() && query.networkId.trim() !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only create intents in this community.`\n );\n }\n\n const effectiveIndexId = context.networkId || query.networkId?.trim() || undefined;\n\n // Fetch profile (the intent graph needs it for inference)\n const _profileGraphStart1 = Date.now();\n const profileResult = await traceGraph(\"profile\", () => invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' as const }));\n const _profileGraphMs1 = Date.now() - _profileGraphStart1;\n const latestUser = profileResult.profile ? undefined : typeof userDb.getUser === \"function\" ? await userDb.getUser() : context.user;\n const approvedProfileFallback = profileResult.profile ? \"\" : buildApprovedProfileFallback(latestUser);\n const userProfile = profileResult.profile ? JSON.stringify(profileResult.profile) : approvedProfileFallback;\n\n // Run inference + verification only (propose mode — no DB persistence)\n const _intentGraphStart1 = Date.now();\n const result = await traceGraph(\"intent\", () => invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile,\n inputContent: query.description,\n operationMode: 'propose' as const,\n ...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),\n }));\n const _intentGraphMs1 = Date.now() - _intentGraphStart1;\n logger.debug(\"Intent graph propose response\", { result });\n\n const verified = result.verifiedIntents || [];\n\n // MCP contexts have no interactive UI for proposal cards — default to auto-approve\n const shouldAutoApprove = query.autoApprove ?? context.isMcp ?? false;\n \n // Extract trace from graph and convert to debugSteps\n const trace = Array.isArray(result.trace) ? result.trace : [];\n const debugSteps = trace.map((t: { node: string; detail?: string; data?: Record<string, unknown> }) => ({\n step: t.node,\n detail: t.detail,\n ...(t.data ? { data: t.data } : {}),\n }));\n \n if (verified.length === 0) {\n // Build a descriptive rejection reason from the trace so the ReACT agent\n // can retry with a better description or ask the user for clarification.\n // When inference produces 0 intents, propose mode exits before verification\n // runs — so we check inference trace first.\n const verificationTrace = debugSteps.find((s: { step: string; detail?: string }) => s.step === \"verification\");\n\n if (!verificationTrace) {\n const inferenceHint =\n debugSteps.find((s: { step: string; detail?: string }) => s.step === \"inference\")?.detail\n ?? \"no intents extracted\";\n return error(\n `No actionable intent was extracted (${inferenceHint}). ` +\n `Please retry with a more specific goal (what kind, what for, and/or timeframe), ` +\n `or ask the user to clarify.`,\n debugSteps,\n );\n }\n\n const rejectionHint =\n verificationTrace.detail ?? \"all candidate intents were filtered as invalid or too vague\";\n return error(\n `Intent verification failed (${rejectionHint}). ` +\n `The description may be too vague or was classified as a statement rather than a goal. ` +\n `Either retry with a more specific description (e.g. include what kind, what for, or a timeframe) ` +\n `or ask the user to clarify what exactly they are looking for.`,\n debugSteps,\n );\n }\n\n // ── Auto-approve path (for MCP agents or explicit opt-in) ──\n if (shouldAutoApprove) {\n const broadIntents = (verified as VerifiedIntent[]).filter(isBroadAttributiveIntent);\n if (broadIntents.length > 0) {\n const first = broadIntents[0];\n const missing = first.verification?.missing_selectional_constraints ?? [];\n const missingHint = missing.length > 0\n ? ` Missing specifics: ${missing.map((m) => m.replace(/_/g, \" \")).join(\", \")}.`\n : \"\";\n return error(\n `${specificityWarningFor(first)}${missingHint} ` +\n `Please ask the user to clarify before creating this signal, or retry with a narrower description.`,\n debugSteps,\n );\n }\n\n const createdIntents: Array<{ description: string; confidence: number | null; speechActType: string | null }> = [];\n const createTimings: Array<{ name: string; durationMs: number; agents: unknown[] }> = [];\n\n for (const v of verified as VerifiedIntent[]) {\n const _createGraphStart = Date.now();\n const createResult = await traceGraph(\"intent\", () => invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile,\n inputContent: v.description,\n operationMode: 'create' as const,\n ...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),\n }));\n const _createGraphMs = Date.now() - _createGraphStart;\n\n createTimings.push({ name: 'intent-create', durationMs: _createGraphMs, agents: createResult.agentTimings ?? [] });\n\n const succeeded = createResult.executionResults?.some((r: ExecutionResult) => r.success);\n if (succeeded) {\n createdIntents.push({\n description: v.description,\n confidence: v.score != null ? Math.round(v.score * 100) / 100 : null,\n speechActType: v.verification?.classification ?? null,\n });\n }\n }\n\n return success({\n created: createdIntents.length > 0,\n count: createdIntents.length,\n intents: createdIntents,\n message: createdIntents.length > 0\n ? `Created ${createdIntents.length} intent${createdIntents.length > 1 ? 's' : ''} successfully. The system will automatically index them and begin searching for matching opportunities.`\n : 'Intent creation failed — the intents could not be persisted.',\n debugSteps,\n _graphTimings: [\n { name: 'profile', durationMs: _profileGraphMs1, agents: profileResult.agentTimings ?? [] },\n { name: 'intent-propose', durationMs: _intentGraphMs1, agents: result.agentTimings ?? [] },\n ...createTimings,\n ],\n });\n }\n\n // ── Proposal path (for web chat with interactive cards) ──\n // Build intent_proposal code fences for each verified intent\n const proposalBlocks = verified.map((v: VerifiedIntent) => {\n const proposalId = crypto.randomUUID();\n const isBroad = isBroadAttributiveIntent(v);\n const data = {\n proposalId,\n description: v.description,\n ...(effectiveIndexId ? { networkId: effectiveIndexId } : {}),\n confidence: v.score != null ? Math.round(v.score * 100) / 100 : null,\n speechActType: v.verification?.classification ?? null,\n semanticEntropy: v.verification?.semantic_entropy ?? null,\n referentialBreadth: v.verification?.referential_breadth ?? null,\n missingSelectionalConstraints: v.verification?.missing_selectional_constraints ?? [],\n specificityWarning: isBroad ? specificityWarningFor(v) : normalizeSpecificityWarning(v.verification?.specificity_warning),\n };\n return (\n \"```intent_proposal\\n\" +\n sanitizeJsonForCodeFence(JSON.stringify(data)) +\n \"\\n```\"\n );\n });\n\n const blocksText = proposalBlocks.join(\"\\n\\n\");\n\n return success({\n proposed: true,\n count: verified.length,\n message: `IMPORTANT: Include the following \\`\\`\\`intent_proposal code blocks EXACTLY as-is in your response (they render as interactive cards for the user to approve or skip):\\n\\n${blocksText}`,\n debugSteps,\n _graphTimings: [\n { name: 'profile', durationMs: _profileGraphMs1, agents: profileResult.agentTimings ?? [] },\n { name: 'intent', durationMs: _intentGraphMs1, agents: result.agentTimings ?? [] },\n ],\n });\n },\n });\n\n const updateIntent = defineTool({\n name: \"update_intent\",\n description:\n \"Updates an existing intent's description. After updating, the system re-processes the intent through inference and verification, \" +\n \"re-evaluates its index assignments, and triggers fresh opportunity discovery with the new description.\\n\\n\" +\n \"**When to use:** When the user wants to refine or change what they're looking for — e.g. narrowing scope, adding specificity, \" +\n \"or pivoting to a different need. Prefer updating over delete+create to preserve the intent's history and existing index links.\\n\\n\" +\n \"**Returns:** Updated `intentId` and `description`, plus a confirmation message. The intent's embeddings and index relevancy scores are recalculated automatically.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to update. Get this from read_intents results.\"),\n description: z.string().describe(\"The updated description of what the user is looking for. Same guidelines as create_intent — should be clear and specific.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n if (!UUID_REGEX.test(intentId)) {\n return error(\"Invalid intent ID format.\");\n }\n\n // Ownership guard: caller must own the intent\n const intent = await deps.systemDb.getIntent(intentId);\n if (!intent || intent.userId !== context.userId) {\n return error(\"Intent not found or you can only update your own intents.\");\n }\n if (intent.archivedAt) {\n return error(\"This intent is archived and cannot be updated. Create a new intent instead.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, verify intent is linked to that index\n if (context.networkId) {\n const db = deps.userDb;\n const intentNetworks = await db.getNetworkIdsForIntent(intentId);\n if (!intentNetworks.includes(context.networkId)) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only update intents linked to this community.`\n );\n }\n }\n\n const _profileGraphStart2 = Date.now();\n const profileResult = await traceGraph(\"profile\", () => invokeWithAbortSignal(graphs.profile, { userId: context.userId, operationMode: 'query' as const }));\n const _profileGraphMs2 = Date.now() - _profileGraphStart2;\n const latestUser = profileResult.profile ? undefined : typeof userDb.getUser === \"function\" ? await userDb.getUser() : context.user;\n const approvedProfileFallback = profileResult.profile ? \"\" : buildApprovedProfileFallback(latestUser);\n const userProfile = profileResult.profile ? JSON.stringify(profileResult.profile) : approvedProfileFallback;\n\n const _intentGraphStart2 = Date.now();\n const result = await traceGraph(\"intent\", () => invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile,\n operationMode: 'update' as const,\n inputContent: query.description,\n targetIntentIds: [intentId],\n ...(context.networkId && { networkId: context.networkId }),\n }));\n const _intentGraphMs2 = Date.now() - _intentGraphStart2;\n\n if (result.executionResults?.some((r: ExecutionResult) => !r.success)) {\n return error(\"Failed to update intent.\");\n }\n if (!result.executionResults?.some((r: ExecutionResult) => r.success)) {\n return error(\n \"Intent update was not applied. The new description may be too broad, too vague, or failed semantic verification. Please ask the user to clarify with a more concrete role, outcome, location, timeframe, domain, or specific need.\",\n );\n }\n return success({\n message: \"Intent updated.\",\n intentId,\n description: query.description,\n _graphTimings: [\n { name: 'profile', durationMs: _profileGraphMs2, agents: profileResult.agentTimings ?? [] },\n { name: 'intent', durationMs: _intentGraphMs2, agents: result.agentTimings ?? [] },\n ],\n });\n },\n });\n\n const deleteIntent = defineTool({\n name: \"delete_intent\",\n description:\n \"Archives (soft-deletes) an intent, removing it from active discovery. The intent is not permanently deleted — it is marked as archived \" +\n \"and no longer participates in opportunity matching or index evaluation.\\n\\n\" +\n \"**When to use:** When the user's need has been fulfilled, is no longer relevant, or was created by mistake. \" +\n \"If the user wants to change the description instead, use update_intent to preserve history.\\n\\n\" +\n \"**Returns:** Confirmation that the intent was archived. Previously created opportunities from this intent remain but won't generate new ones.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to archive. Get this from read_intents results.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n if (!UUID_REGEX.test(intentId)) {\n return error(\"Invalid intent ID format.\");\n }\n\n // Ownership guard: caller must own the intent\n const intent = await deps.systemDb.getIntent(intentId);\n if (!intent || intent.userId !== context.userId) {\n return error(\"Intent not found or you can only delete your own intents.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, verify intent is linked to that index\n if (context.networkId) {\n const db = deps.userDb;\n const intentNetworks = await db.getNetworkIdsForIntent(intentId);\n if (!intentNetworks.includes(context.networkId)) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only delete intents linked to this community.`\n );\n }\n }\n\n const _deleteIntentGraphStart = Date.now();\n const result = await traceGraph(\"intent\", () => invokeWithAbortSignal(graphs.intent, {\n userId: context.userId,\n userProfile: \"\",\n operationMode: 'delete' as const,\n targetIntentIds: [intentId],\n ...(context.networkId && { networkId: context.networkId }),\n }));\n const _deleteIntentGraphMs = Date.now() - _deleteIntentGraphStart;\n\n if (result.executionResults?.some((r: ExecutionResult) => !r.success)) {\n return error(\"Failed to delete intent.\");\n }\n return success({\n message: \"Intent archived successfully.\",\n _graphTimings: [{ name: 'intent', durationMs: _deleteIntentGraphMs, agents: result.agentTimings ?? [] }],\n });\n },\n });\n\n // ─────────────────────────────────────────────────────────────────────────────\n // INTENT–INDEX JUNCTION (link / list / unlink)\n // ─────────────────────────────────────────────────────────────────────────────\n\n const createIntentIndex = defineTool({\n name: \"create_intent_index\",\n description:\n \"Manually links an intent to an index (community), making it visible to other members and eligible for opportunity discovery within that index. \" +\n \"Normally intents are auto-assigned to relevant indexes on creation, but use this to explicitly add an intent to an additional index.\\n\\n\" +\n \"**When to use:** When the user wants to share an existing intent with a specific community they belong to, \" +\n \"or when auto-assignment missed an index the user considers relevant.\\n\\n\" +\n \"**Returns:** Confirmation that the link was created. The intent will now appear in that index's intent list and participate in discovery within that community.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to link. Get this from read_intents results.\"),\n networkId: z.string().optional().describe(\"The UUID of the index to link the intent to. Get this from read_networks. Defaults to the scoped index in index-scoped chats.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n const networkId = query.networkId?.trim() || context.networkId || \"\";\n if (!UUID_REGEX.test(intentId) || !UUID_REGEX.test(networkId)) {\n return error(\"Invalid ID format. Both must be UUIDs.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, only allow linking to that index\n if (context.networkId && networkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only link intents to this community.`\n );\n }\n\n const _createIntentIndexGraphStart = Date.now();\n const result = await traceGraph(\"intent_network\", () => invokeWithAbortSignal(graphs.intentIndex, {\n userId: context.userId,\n networkId,\n intentId,\n operationMode: 'create' as const,\n skipEvaluation: true,\n }));\n const _createIntentIndexGraphMs = Date.now() - _createIntentIndexGraphStart;\n\n if (result.mutationResult) {\n if (result.mutationResult.success) {\n const alreadyExisted = result.mutationResult.message?.includes('already in this network') ?? false;\n return success({\n created: !alreadyExisted,\n message: result.mutationResult.message,\n _graphTimings: [{ name: 'intent_network', durationMs: _createIntentIndexGraphMs, agents: result.agentTimings ?? [] }],\n });\n }\n return error(result.mutationResult.error || \"Failed to link intent to network.\");\n }\n return error(\"Failed to link intent to network.\");\n },\n });\n\n const readIntentIndexes = defineTool({\n name: \"read_intent_indexes\",\n description:\n \"Reads the many-to-many links between intents and indexes. Use this to understand which intents are shared in which communities, \" +\n \"and which indexes a specific intent belongs to.\\n\\n\" +\n \"**Usage modes:**\\n\" +\n \"- With networkId: lists all intents linked to that index. Add userId to filter to one member's intents in that index.\\n\" +\n \"- With intentId + networkId: checks whether a specific intent is linked to a specific index.\\n\" +\n \"- intentId alone requires a networkId (the system won't reveal all indexes an intent is in).\\n\\n\" +\n \"**When to use:** To audit which intents are active in a community, verify an intent's index assignment before unlinking, \" +\n \"or check if a newly created intent was auto-assigned to the expected index.\\n\\n\" +\n \"**Returns:** List of intent-index links with relevancy scores (0-1, how well the intent fits the index's purpose).\",\n querySchema: z.object({\n intentId: z.string().optional().describe(\"Intent UUID — check if this specific intent is linked to the specified index. Must be combined with networkId.\"),\n networkId: z.string().optional().describe(\"Index UUID — list all intents linked to this index. Get this from read_networks. Defaults to scoped index in index-scoped chats.\"),\n userId: z.string().optional().describe(\"Filter results to this user's intents within the specified index. Omit to see all members' intents.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() || undefined;\n let networkId = query.networkId?.trim() || context.networkId || undefined;\n const queryUserId = query.userId?.trim() || undefined;\n\n if (intentId && !UUID_REGEX.test(intentId)) {\n return error(\"Invalid intent ID format.\");\n }\n if (networkId && !UUID_REGEX.test(networkId)) {\n return error(\"Invalid network ID format.\");\n }\n if (!intentId && !networkId) {\n return error(\"Provide networkId or intentId.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, only allow querying that index\n if (context.networkId && networkId && networkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only read intent links from this community.`\n );\n }\n\n // When only intentId is provided, enforce scope - don't reveal all linked indexes\n if (intentId && !networkId) {\n if (context.networkId) {\n // When scoped, only check if intent is linked to the scoped index\n networkId = context.networkId;\n } else {\n // When unscoped, still don't reveal all indexes - require explicit networkId\n return error(\n \"Please provide a networkId to check if the intent is linked to a specific network. Listing all linked networks is not supported.\"\n );\n }\n }\n\n const _readIntentIndexGraphStart = Date.now();\n const result = await traceGraph(\"intent_network\", () => invokeWithAbortSignal(graphs.intentIndex, {\n userId: context.userId,\n networkId,\n intentId,\n operationMode: 'read' as const,\n queryUserId,\n }));\n const _readIntentIndexGraphMs = Date.now() - _readIntentIndexGraphStart;\n\n if (result.error) {\n return error(result.error);\n }\n if (result.readResult) {\n return success({ ...result.readResult, _graphTimings: [{ name: 'intent_network', durationMs: _readIntentIndexGraphMs, agents: result.agentTimings ?? [] }] });\n }\n return error(\"Failed to fetch intent-network links.\");\n },\n });\n\n const deleteIntentIndex = defineTool({\n name: \"delete_intent_index\",\n description:\n \"Removes the link between an intent and an index. The intent itself is NOT deleted — it just stops being visible in that community \" +\n \"and no longer participates in opportunity discovery within that index. The intent may still be linked to other indexes.\\n\\n\" +\n \"**When to use:** When the user wants to withdraw an intent from a specific community without archiving it entirely. \" +\n \"Use read_intent_indexes first to verify the link exists.\\n\\n\" +\n \"**Returns:** Confirmation that the link was removed. To fully remove an intent, use delete_intent instead.\",\n querySchema: z.object({\n intentId: z.string().describe(\"The UUID of the intent to unlink. Get this from read_intents or read_intent_indexes.\"),\n networkId: z.string().optional().describe(\"The UUID of the index to unlink from. Get this from read_networks. Defaults to the scoped index in index-scoped chats.\"),\n }),\n handler: async ({ context, query }) => {\n const scopeErr = await ensureScopedMembership(context, deps.systemDb);\n if (scopeErr) return error(scopeErr);\n const intentId = query.intentId?.trim() ?? \"\";\n const networkId = query.networkId?.trim() || context.networkId || \"\";\n if (!UUID_REGEX.test(intentId) || !UUID_REGEX.test(networkId)) {\n return error(\"Invalid ID format. Both must be UUIDs.\");\n }\n\n // Strict scope enforcement: when chat is index-scoped, only allow unlinking from that index\n if (context.networkId && networkId !== context.networkId) {\n return error(\n `This chat is scoped to ${context.indexName ?? 'this index'}. You can only unlink intents from this community.`\n );\n }\n\n const _deleteIntentIndexGraphStart = Date.now();\n const result = await traceGraph(\"intent_network\", () => invokeWithAbortSignal(graphs.intentIndex, {\n userId: context.userId,\n networkId,\n intentId,\n operationMode: 'delete' as const,\n }));\n const _deleteIntentIndexGraphMs = Date.now() - _deleteIntentIndexGraphStart;\n\n if (result.mutationResult) {\n if (result.mutationResult.success) {\n return success({\n deleted: true,\n message: result.mutationResult.message,\n _graphTimings: [{ name: 'intent_network', durationMs: _deleteIntentIndexGraphMs, agents: result.agentTimings ?? [] }],\n });\n }\n return error(result.mutationResult.error || \"Failed to unlink.\");\n }\n return error(\"Failed to unlink intent from network.\");\n },\n });\n\n const searchIntents = defineTool({\n name: \"search_intents\",\n description:\n \"Text-searches the authenticated user's own active signals by description. Case-insensitive substring \" +\n \"match over the signal's payload and summary. Use when the user references a past signal they wrote \" +\n '(\"find my signal about React mentorship\") or wants to audit what they\\'ve posted.\\n\\n' +\n \"For discovery of OTHER users' signals that match a query, use discover_opportunities(searchQuery=...) \" +\n \"instead — that runs semantic matching across the user's networks.\\n\\n\" +\n \"**Returns:** `intents: [{ id, payload, summary, createdAt }]`, most recent first, up to `limit` (default 25).\",\n querySchema: z.object({\n query: z.string().min(1).describe(\"Text to match against payload and summary (case-insensitive).\"),\n limit: z\n .number()\n .int()\n .positive()\n .max(100)\n .optional()\n .describe(\"Maximum intents to return (default 25, max 100).\"),\n }),\n handler: async ({ context, query }) => {\n const rows = await userDb.searchOwnIntents(query.query, query.limit ?? 25);\n logger.verbose(\"search_intents\", { userId: context.userId, query: query.query, matched: rows.length });\n return success({ intents: rows });\n },\n });\n\n return [readIntents, createIntent, updateIntent, deleteIntent, createIntentIndex, readIntentIndexes, deleteIntentIndex, searchIntents] as const;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintenance.graph.d.ts","sourceRoot":"/","sources":["maintenance/maintenance.graph.ts"],"names":[],"mappings":"AAoBA,wFAAwF;AACxF,MAAM,WAAW,wBAAwB;IACvC,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/L,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAClF,mEAAmE;IACnE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3D,gGAAgG;IAChG,8BAA8B,CAC5B,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,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,EAAE,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E;AAED,qDAAqD;AACrD,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpK;AAED;;;GAGG;AACH,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,KAAK;gBAFL,QAAQ,EAAE,wBAAwB,EAClC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,qBAAqB;IAGtC,gDAAgD;IAChD,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4KZ"}
|
|
@@ -102,7 +102,6 @@ export class MaintenanceGraphFactory {
|
|
|
102
102
|
const rediscoverNode = async (state) => {
|
|
103
103
|
try {
|
|
104
104
|
const bucket = Math.floor(Date.now() / (6 * 60 * 60 * 1000));
|
|
105
|
-
let enqueued = 0;
|
|
106
105
|
const results = await Promise.allSettled(state.activeIntents.map((intent) => this.queue.addJob({ intentId: intent.id, userId: state.userId }, { priority: 10, jobId: `rediscovery-${state.userId}-${intent.id}-${bucket}` })));
|
|
107
106
|
for (const r of results) {
|
|
108
107
|
if (r.status === 'rejected') {
|
|
@@ -110,7 +109,7 @@ export class MaintenanceGraphFactory {
|
|
|
110
109
|
logger.error(`[MaintenanceGraph] Rediscovery job enqueue failed: ${errMsg}`);
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
|
-
enqueued = results.filter((r) => r.status === 'fulfilled').length;
|
|
112
|
+
const enqueued = results.filter((r) => r.status === 'fulfilled').length;
|
|
114
113
|
// Record last run timestamp
|
|
115
114
|
if (enqueued > 0) {
|
|
116
115
|
try {
|