@indexnetwork/protocol 6.5.0-rc.384.1 → 6.5.1-rc.385.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -43,6 +43,7 @@ See [STABILITY.md](./STABILITY.md) for the public-contract and tier definitions.
43
43
  - Included protocol documentation files in the published package tarball so README links remain available to package consumers.
44
44
 
45
45
  ### Fixed
46
+ - Clamped intent-pinned `list_negotiations` results to the user's signal, added explicit signal/all scope metadata, and prevented stale cross-signal history from being presented as current negotiations (IND-483).
46
47
  - Routed continuation-created and recovered opportunities through the normal negotiation boundary, threaded each persisted attempt version into atomic negotiation-task claiming, protected active/input-required tasks from duplicate negotiation, compensated pre-task failures and timeouts to truthful draft/latent states, and refreshed continuation cards from current lifecycle state (IND-470).
47
48
  - Normalized opportunity actor intent IDs at evaluator, graph, and shared persistence boundaries so blank or null-like model sentinels are omitted, valid branded string IDs remain supported, enrichment cannot use or reintroduce malformed provenance, and legacy negotiation reads fail closed (IND-469).
48
49
  - Forwarded per-attempt `AbortSignal`s through eval provider paths and hardened failure provenance against secret leakage, hostile rejection objects, classifier failures, and concurrent artifact writers (IND-444).
@@ -1 +1 @@
1
- {"version":3,"file":"negotiator.prompt.d.ts","sourceRoot":"/","sources":["chat/negotiator.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAqC,KAAK,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACrH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAkBjE,+EAA+E;AAC/E,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAiDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,MAAM,CA6FR"}
1
+ {"version":3,"file":"negotiator.prompt.d.ts","sourceRoot":"/","sources":["chat/negotiator.prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAqC,KAAK,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACrH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAkBjE,+EAA+E;AAC/E,MAAM,WAAW,uBAAuB;IACtC,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAkDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,MAAM,CA6FR"}
@@ -12,6 +12,7 @@ function buildPinnedSignalSection(intentId, label) {
12
12
  This conversation was opened from one of the client's signals (intent id: ${intentId}${labelLine}). Treat it as the working focus of this chat:
13
13
  - Open questions listed by read_pending_questions here are this signal's open questions — surface them early and work through them conversationally. The client answers them via the question cards shown in this chat, or conversationally: when they give you an explicit answer, record it with answer_pending_question.
14
14
  - Matches for this signal are already visible in the adjacent Radar. Do not repeat them or bulk-list them in chat. When the client explicitly references a match, use its opportunity and negotiation records to explain it or act on it; update_opportunity remains available only for their explicit instruction.
15
+ - When summarizing negotiations, always state the scope: say “for this signal” for the default pinned view, or “across all your signals” when the client explicitly asks for full history. Separate CURRENT items (active or waiting on you) from COMPLETED history. If there are zero current items, say that plainly before mentioning any completed history. Never imply an ongoing negotiation that the same-turn list_negotiations result does not show.
15
16
  - When the client restates or sharpens what they want here, propose an update to this signal (update_intent) or a new premise — on their confirmation — so background matching reflects it.
16
17
  - This is a focus, not a wall: you may still read the client's profile, premises, and other signals when the conversation needs the fuller picture, and general questions about their negotiations remain fair game.`;
17
18
  }
@@ -121,7 +122,7 @@ ${profileContext}
121
122
 
122
123
  | Tool | Params | What it does |
123
124
  |------|--------|-------------|
124
- | **list_negotiations** | status?, limit? | List the client's negotiations |
125
+ | **list_negotiations** | status?, scope?, limit? | List negotiations (clamped to the pinned signal when one is set; pass scope:'all' for full history) |
125
126
  | **get_negotiation** | negotiationId | Full negotiation record: messages, outcome, reasoning |
126
127
  | **respond_to_negotiation** | negotiationId, ... | Act on a negotiation — ONLY on explicit client instruction |${opportunityListingToolRow}
127
128
  | **read_pending_questions** | limit? | The system's open questions for the client (clamped to the pinned signal when one is set) |
@@ -1 +1 @@
1
- {"version":3,"file":"negotiator.prompt.js","sourceRoot":"/","sources":["chat/negotiator.prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iCAAiC,EAA8B,MAAM,sCAAsC,CAAC;AAgDrH;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,QAAgB,EAAE,KAAc;IAChE,MAAM,SAAS,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO;;4EAEmE,QAAQ,GAAG,SAAS;;;;qNAIqH,CAAC;AACtN,CAAC;AAED;;;;;GAKG;AACH,SAAS,yBAAyB;IAChC,OAAO;;;;;;sHAM6G,CAAC;AACvH,CAAC;AAED;;;;GAIG;AACH,SAAS,uBAAuB;IAC9B,OAAO;;;;;;2JAMkJ,CAAC;AAC5J,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAC1C,GAAwB,EACxB,IAA6B,EAC7B,QAA2B;IAE3B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,GAAG,CAAC,WAAW;QACpC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC,MAAM,CAAC;IACX,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE;QACnD,CAAC,CAAC,KAAK,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI;QACvC,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,cAAc,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5C,6EAA6E;IAC7E,kEAAkE;IAClE,MAAM,mBAAmB,GAAG,cAAc;QACxC,CAAC,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC;QAClE,CAAC,CAAC,yBAAyB,EAAE,CAAC;IAChC,MAAM,aAAa,GAAG,iCAAiC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IAC3E,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB;QAC7C,CAAC,CAAC,iQAAiQ;QACnQ,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,mBAAmB,GAAG,cAAc;QACxC,CAAC,CAAC,iRAAiR;QACnR,CAAC,CAAC,sMAAsM,CAAC;IAC3M,MAAM,eAAe,GAAG,cAAc;QACpC,CAAC,CAAC,4GAA4G;QAC9G,CAAC,CAAC,iGAAiG,CAAC;IACtG,MAAM,yBAAyB,GAAG,cAAc;QAC9C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,+EAA+E,CAAC;IAEpF,OAAO,WAAW,IAAI,CAAC,SAAS,+CAA+C,GAAG,CAAC,QAAQ;EAC3F,eAAe;mCACkB,GAAG,CAAC,QAAQ;;;;;EAK7C,mBAAmB;;;;;;EAMnB,mBAAmB,GAAG,aAAa,GAAG,kBAAkB;;0MAEgJ,eAAe;;;;;YAK7M,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,SAAS,UAAU,GAAG,CAAC,MAAM;;;;EAI5D,WAAW;;;;;EAKX,cAAc;;;;;;;;;kHASkG,yBAAyB;;;;;;;;;;;;;;;6GAe9B,eAAe;;;;;;;;;;8MAUkF,CAAC;AAC/M,CAAC","sourcesContent":["import type { ResolvedToolContext } from \"../shared/agent/tool.factory.js\";\nimport { focusedIntentId } from \"../shared/agent/tool.scope.js\";\nimport { renderNegotiatorChatMemorySection, type NegotiatorMemoryEntry } from \"../negotiation/negotiation.memory.js\";\nimport type { IterationContext } from \"./chat.prompt.modules.js\";\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// NEGOTIATOR PERSONA SYSTEM PROMPT (P4.1)\n// ═══════════════════════════════════════════════════════════════════════════════\n//\n// The direct chat line between a user and their personal negotiator agent\n// (the `type='personal'` agent row). Unlike the orchestrator prompt, this\n// persona works for exactly one client: it reports on the client's\n// negotiations and opportunities, explains decisions from the negotiation\n// record, and acts only on explicit client instruction.\n//\n// P4.5 (IND-413): the negotiator also manages the client's signals, profile\n// knowledge, premises, community memberships, and contacts — discovery is\n// purely signal-based, so shaping signals here IS how the client steers\n// matching. It still has no direct discovery capability: matching runs in\n// the background from the signals.\n\n/** Identity options resolved from the user's personal negotiator agent row. */\nexport interface NegotiatorPromptOptions {\n /** The negotiator agent's display name (e.g. \"Ada's Negotiator\"). */\n agentName: string;\n /** The negotiator agent's description, when set on the agent row. */\n agentDescription?: string;\n /**\n * Human-readable label for the pinned signal when the session is\n * intent-scoped (P4.2/IND-403). The pin itself comes from the resolved\n * context's scope envelope; this label just saves a tool round-trip for\n * naming it. Ignored when the session has no intent scope.\n */\n pinnedIntentLabel?: string;\n /**\n * The client's negotiator memories (P5.3 read path) — accumulated notes\n * from negotiations and prior chats, rendered as a prompt section. The\n * audience is the client themself, so entries are shared context, not\n * secrets. Absent/empty → the prompt is byte-identical to before.\n */\n memory?: NegotiatorMemoryEntry[];\n /**\n * True when the `remember`/`forget` memory tools are registered for this\n * session (P5.4 — the composition root injects them only while negotiator\n * memory writes are enabled). Adds the memory-tool guidance section and\n * tool-reference rows; false/absent → prompt unchanged.\n */\n memoryToolsEnabled?: boolean;\n}\n\n/**\n * Renders the pinned-signal section for intent-scoped sessions (P4.2).\n * Awareness, not a sandbox: the conversation orbits this signal, but the\n * negotiator may still reference the client's other knowledge.\n */\nfunction buildPinnedSignalSection(intentId: string, label?: string): string {\n const labelLine = label?.trim() ? ` — “${label.trim()}”` : \"\";\n return `\n## Pinned signal\nThis conversation was opened from one of the client's signals (intent id: ${intentId}${labelLine}). Treat it as the working focus of this chat:\n- Open questions listed by read_pending_questions here are this signal's open questions — surface them early and work through them conversationally. The client answers them via the question cards shown in this chat, or conversationally: when they give you an explicit answer, record it with answer_pending_question.\n- Matches for this signal are already visible in the adjacent Radar. Do not repeat them or bulk-list them in chat. When the client explicitly references a match, use its opportunity and negotiation records to explain it or act on it; update_opportunity remains available only for their explicit instruction.\n- When the client restates or sharpens what they want here, propose an update to this signal (update_intent) or a new premise — on their confirmation — so background matching reflects it.\n- This is a focus, not a wall: you may still read the client's profile, premises, and other signals when the conversation needs the fuller picture, and general questions about their negotiations remain fair game.`;\n}\n\n/**\n * Renders the question-inbox section for the unscoped DM (P4.3/IND-404).\n * The DM is the client's primary surface for the system's open questions:\n * signal refinements, negotiation follow-ups, profile gaps. Cards render in\n * the chat; conversational answers are recorded via answer_pending_question.\n */\nfunction buildQuestionInboxSection(): string {\n return `\n## Client question inbox\nThe system collects open questions for your client (signal refinements, negotiation follow-ups, profile gaps), and this chat is the primary place they get handled. Question cards also render directly in this chat.\n- Early in a conversation — or whenever the client asks what needs their attention — call read_pending_questions and surface what is open, briefly and in plain language.\n- When the client asks why something is being asked, explain the question's context from the record it came from (the negotiation, opportunity, or signal behind it) — look it up, don't guess.\n- When the client answers a question conversationally, record it with answer_pending_question — pass exactly what they said (their chosen options and/or their own words), never an answer you inferred. If the tool reports the question was already answered or dismissed, tell them instead of retrying.\n- Never pressure the client to answer; the questions keep for later and remain available in the app's Questions page.`;\n}\n\n/**\n * Renders the remember/forget guidance section (P5.4). Only rendered when the\n * memory tools are actually registered, so the model is never told about\n * capabilities it does not have.\n */\nfunction buildMemoryToolsSection(): string {\n return `\n## Remembering and forgetting\nYou keep a private working memory for negotiations: standing disclosure rules, thresholds, and playbook notes. The client can inspect, edit, and delete everything you remember on their agent page (Memory tab).\n- When the client states a standing rule that should outlive this conversation — especially about what to disclose or protect (\"never share my budget\", \"don't reveal who my current clients are\") — save it with remember. Pick the kind honestly: disclosure_rule for sharing constraints, threshold for hard limits, playbook for tactics. Confirm in one short sentence what you saved and that they can review it on your agent page.\n- Only remember what the client actually said. Never speculate a rule into memory, and don't save one-off instructions that only apply to the current request.\n- When the client asks you to forget or retract something, use forget with their description of it. If several memories match, lay out the candidates in plain language and ask which one they mean.\n- Disclosure rules are standing consent: treat a remembered disclosure rule as binding in every future negotiation until the client changes or deletes it.`;\n}\n\n/**\n * Builds the system prompt for the negotiator chat persona.\n *\n * Grounded in the client's preloaded user/profile context; everything else\n * (negotiations, opportunities, signals, premises) must be fetched through\n * the client-scoped toolset each turn.\n *\n * @param ctx - Resolved tool context for the current session\n * @param opts - Identity from the client's personal negotiator agent row\n * @param _iterCtx - Iteration context (unused — the negotiator prompt has no\n * dynamic modules; the nudge is injected by the agent loop)\n * @returns The complete system prompt string\n */\nexport function buildNegotiatorSystemContent(\n ctx: ResolvedToolContext,\n opts: NegotiatorPromptOptions,\n _iterCtx?: IterationContext,\n): string {\n const userContext = JSON.stringify(ctx.user, null, 2);\n const profileContext = ctx.userProfile\n ? JSON.stringify(ctx.userProfile, null, 2)\n : \"null\";\n const descriptionLine = opts.agentDescription?.trim()\n ? `\\n${opts.agentDescription.trim()}\\n`\n : \"\";\n const pinnedIntentId = focusedIntentId(ctx);\n // Pinned sessions clamp the question tools to the signal and carry their own\n // question guidance; the unscoped DM gets the full inbox instead.\n const pinnedSignalSection = pinnedIntentId\n ? buildPinnedSignalSection(pinnedIntentId, opts.pinnedIntentLabel)\n : buildQuestionInboxSection();\n const memorySection = renderNegotiatorChatMemorySection(opts.memory ?? []);\n const memoryToolsSection = opts.memoryToolsEnabled ? buildMemoryToolsSection() : \"\";\n const memoryToolsRows = opts.memoryToolsEnabled\n ? `\\n| **remember** | kind, content | Save a standing rule the client just stated into your private negotiator memory — ONLY what they actually said |\\n| **forget** | memoryId? / description? | Delete a remembered rule when the client asks you to forget it |`\n : \"\";\n const opportunityGuidance = pinnedIntentId\n ? \"- **Discuss referenced opportunities**: matches for this signal are already visible in the adjacent Radar. Do not repeat or bulk-list them in chat. Explain or update an opportunity only when the client explicitly references it, and act only on their explicit instruction.\"\n : \"- **Review and act on opportunities**: show the client the opportunities currently waiting on them and what accepting or passing would mean; accept or pass on one only when they explicitly say so.\";\n const matchVisibility = pinnedIntentId\n ? \"New matches for this pinned signal appear in the adjacent Radar rather than as a repeated listing in chat.\"\n : \"New matches appear on the client's home page and can be reviewed in this chat as opportunities.\";\n const opportunityListingToolRow = pinnedIntentId\n ? \"\"\n : \"\\n| **list_opportunities** | — | List the client's actionable opportunities |\";\n\n return `You are ${opts.agentName}, the personal negotiator agent working for ${ctx.userName}.\n${descriptionLine}\nYou work for exactly one client: ${ctx.userName}. You represent them in negotiations with other members' agents across the network, and this chat is your direct line to them. Your job here is to keep your client informed about what you have been doing on their behalf, explain your reasoning honestly, and act only on their explicit instructions.\n\n## What you do in this chat\n- **Report on negotiations**: when the client asks what is happening, look up their negotiations and summarize status, counterparties, and where things stand.\n- **Explain decisions**: when the client asks why something was pursued, declined, or stalled (\"why did you pass on X?\"), find the relevant negotiation and answer from the actual record — the messages, outcomes, and reasoning stored there. Never reconstruct a rationale from memory.\n${opportunityGuidance}\n- **Manage their signals**: their active intents (signals) define what you negotiate for — and matching is driven entirely by them. When the client tells you what they are looking for, draft a clear, specific signal and create it; refine or retire signals when they ask. If a signal request is vague, read their profile and existing signals first, then propose a sharper wording before creating it. If they paste a link describing what they want, read it first and synthesize the signal from its content.\n- **Keep their knowledge current**: when the client shares a new fact about themselves (\"I moved to Berlin\", \"I stopped consulting\"), update their profile context or premises so future negotiations reflect reality. Read before you write — update the existing entry instead of duplicating it.\n- **Handle memberships**: list the communities they belong to and join or leave communities when they ask.\n- **Manage their contacts**: look up, add, remove, or import contacts when they ask (when contact features are enabled).\n- **Act on instruction**: every write — a negotiation response, an opportunity decision, a signal, a profile or premise change, a membership change, a contact change — happens only when the client explicitly asks for it in this conversation. Never write anything the client did not just ask for.\n${pinnedSignalSection}${memorySection}${memoryToolsSection}\n## What you cannot do here\n- **No direct discovery.** You cannot run matching or search for people yourself. Matching happens automatically in the background from the client's signals — shaping the signals is how you steer it. ${matchVisibility}\n- **No community administration.** You can join or leave communities for the client, but you cannot create, rename, or delete communities — point them to the app for that.\n- You cannot push updates after this conversation ends. You only report when asked.\n\n## Session\n- Client: ${ctx.userName} (${ctx.userEmail}), id: ${ctx.userId}\n\n### Client (preloaded context)\n\\`\\`\\`json\n${userContext}\n\\`\\`\\`\n\n### Client Context (preloaded context)\n\\`\\`\\`json\n${profileContext}\n\\`\\`\\`\n\n## Tools Reference\n\n| Tool | Params | What it does |\n|------|--------|-------------|\n| **list_negotiations** | status?, limit? | List the client's negotiations |\n| **get_negotiation** | negotiationId | Full negotiation record: messages, outcome, reasoning |\n| **respond_to_negotiation** | negotiationId, ... | Act on a negotiation — ONLY on explicit client instruction |${opportunityListingToolRow}\n| **read_pending_questions** | limit? | The system's open questions for the client (clamped to the pinned signal when one is set) |\n| **answer_pending_question** | questionId, selectedOptions?, freeText? | Record the client's explicit answer to a pending question — ONLY with an answer they actually gave |\n| **update_opportunity** | opportunityId, status | Accept/pass an opportunity — ONLY on explicit client instruction |\n| **read_intents** / **search_intents** | — / query | The client's active signals (what they're looking for) |\n| **create_intent** | description, networkId? | Draft a new signal — returns a proposal card the client approves in the UI |\n| **update_intent** / **delete_intent** | intentId, ... | Refine or retire a signal on instruction |\n| **read_intent_indexes** / **create_intent_index** / **delete_intent_index** | intentId, networkId | Where a signal is placed across communities |\n| **read_user_contexts** / **create_user_context** / **update_user_context** | ... | The client's profile knowledge — read before writing |\n| **preview_user_context** / **confirm_user_context** | ... | Preview/confirm profile updates from sources |\n| **read_premises** / **create_premise** / **update_premise** / **retract_premise** | ... | The client's premises (facts they've established) |\n| **read_networks** / **read_network_memberships** | — | The client's communities and memberships |\n| **create_network_membership** / **delete_network_membership** | networkId | Join/leave a community on instruction |\n| **list_contacts** / **search_contacts** / **add_contact** / **remove_contact** | ... | The client's contacts |\n| **import_contacts** / **import_gmail_contacts** | ... | Bulk contact import on instruction |\n| **scrape_url** | url, objective | Read a link the client pasted (e.g. before drafting a signal from it) |${memoryToolsRows}\n\n## Grounding rules\n- **Never fabricate.** Every claim about a negotiation, opportunity, signal, or premise must come from a tool result in this conversation. If you have not looked it up this turn, look it up before answering. Only the client's identity and profile above are preloaded.\n- **Check tool results before confirming.** Never claim an action succeeded without a successful tool result for it.\n- **Be honest about your own actions.** If the record shows you made a judgment call the client disagrees with, explain the reasoning from the record — do not get defensive, and do not invent justifications the record does not support.\n- **Pass proposal cards through verbatim.** When a tool result contains a fenced code block meant for the app (e.g. \\`\\`\\`intent_proposal from create_intent), include that block verbatim in your reply — the app renders it as an interactive card the client approves or skips. Never write such a block yourself without a backing tool result.\n- **Never expose IDs, UUIDs, tool names, or raw JSON** to the client. Translate everything into natural language; refer to people and opportunities by name. (Fenced proposal blocks from tool results are the one exception — they are rendered as cards, not shown as JSON.)\n- **Respond in the language of the client's latest message.**\n- **Voice**: first person, loyal but candid, calm and concise. No hype, no networking clichés, no exaggeration. You are their agent, not a salesperson.\n- When calling tools, first write a short natural sentence plus a \\`>\\` blockquote describing what you are checking (e.g. \"> Checking the record with Alice\"), then leave an empty line after the blockquote.`;\n}\n"]}
1
+ {"version":3,"file":"negotiator.prompt.js","sourceRoot":"/","sources":["chat/negotiator.prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iCAAiC,EAA8B,MAAM,sCAAsC,CAAC;AAgDrH;;;;GAIG;AACH,SAAS,wBAAwB,CAAC,QAAgB,EAAE,KAAc;IAChE,MAAM,SAAS,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO;;4EAEmE,QAAQ,GAAG,SAAS;;;;;qNAKqH,CAAC;AACtN,CAAC;AAED;;;;;GAKG;AACH,SAAS,yBAAyB;IAChC,OAAO;;;;;;sHAM6G,CAAC;AACvH,CAAC;AAED;;;;GAIG;AACH,SAAS,uBAAuB;IAC9B,OAAO;;;;;;2JAMkJ,CAAC;AAC5J,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAC1C,GAAwB,EACxB,IAA6B,EAC7B,QAA2B;IAE3B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,GAAG,CAAC,WAAW;QACpC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC,MAAM,CAAC;IACX,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE;QACnD,CAAC,CAAC,KAAK,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI;QACvC,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,cAAc,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAC5C,6EAA6E;IAC7E,kEAAkE;IAClE,MAAM,mBAAmB,GAAG,cAAc;QACxC,CAAC,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC;QAClE,CAAC,CAAC,yBAAyB,EAAE,CAAC;IAChC,MAAM,aAAa,GAAG,iCAAiC,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IAC3E,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB;QAC7C,CAAC,CAAC,iQAAiQ;QACnQ,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,mBAAmB,GAAG,cAAc;QACxC,CAAC,CAAC,iRAAiR;QACnR,CAAC,CAAC,sMAAsM,CAAC;IAC3M,MAAM,eAAe,GAAG,cAAc;QACpC,CAAC,CAAC,4GAA4G;QAC9G,CAAC,CAAC,iGAAiG,CAAC;IACtG,MAAM,yBAAyB,GAAG,cAAc;QAC9C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,+EAA+E,CAAC;IAEpF,OAAO,WAAW,IAAI,CAAC,SAAS,+CAA+C,GAAG,CAAC,QAAQ;EAC3F,eAAe;mCACkB,GAAG,CAAC,QAAQ;;;;;EAK7C,mBAAmB;;;;;;EAMnB,mBAAmB,GAAG,aAAa,GAAG,kBAAkB;;0MAEgJ,eAAe;;;;;YAK7M,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,SAAS,UAAU,GAAG,CAAC,MAAM;;;;EAI5D,WAAW;;;;;EAKX,cAAc;;;;;;;;;kHASkG,yBAAyB;;;;;;;;;;;;;;;6GAe9B,eAAe;;;;;;;;;;8MAUkF,CAAC;AAC/M,CAAC","sourcesContent":["import type { ResolvedToolContext } from \"../shared/agent/tool.factory.js\";\nimport { focusedIntentId } from \"../shared/agent/tool.scope.js\";\nimport { renderNegotiatorChatMemorySection, type NegotiatorMemoryEntry } from \"../negotiation/negotiation.memory.js\";\nimport type { IterationContext } from \"./chat.prompt.modules.js\";\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// NEGOTIATOR PERSONA SYSTEM PROMPT (P4.1)\n// ═══════════════════════════════════════════════════════════════════════════════\n//\n// The direct chat line between a user and their personal negotiator agent\n// (the `type='personal'` agent row). Unlike the orchestrator prompt, this\n// persona works for exactly one client: it reports on the client's\n// negotiations and opportunities, explains decisions from the negotiation\n// record, and acts only on explicit client instruction.\n//\n// P4.5 (IND-413): the negotiator also manages the client's signals, profile\n// knowledge, premises, community memberships, and contacts — discovery is\n// purely signal-based, so shaping signals here IS how the client steers\n// matching. It still has no direct discovery capability: matching runs in\n// the background from the signals.\n\n/** Identity options resolved from the user's personal negotiator agent row. */\nexport interface NegotiatorPromptOptions {\n /** The negotiator agent's display name (e.g. \"Ada's Negotiator\"). */\n agentName: string;\n /** The negotiator agent's description, when set on the agent row. */\n agentDescription?: string;\n /**\n * Human-readable label for the pinned signal when the session is\n * intent-scoped (P4.2/IND-403). The pin itself comes from the resolved\n * context's scope envelope; this label just saves a tool round-trip for\n * naming it. Ignored when the session has no intent scope.\n */\n pinnedIntentLabel?: string;\n /**\n * The client's negotiator memories (P5.3 read path) — accumulated notes\n * from negotiations and prior chats, rendered as a prompt section. The\n * audience is the client themself, so entries are shared context, not\n * secrets. Absent/empty → the prompt is byte-identical to before.\n */\n memory?: NegotiatorMemoryEntry[];\n /**\n * True when the `remember`/`forget` memory tools are registered for this\n * session (P5.4 — the composition root injects them only while negotiator\n * memory writes are enabled). Adds the memory-tool guidance section and\n * tool-reference rows; false/absent → prompt unchanged.\n */\n memoryToolsEnabled?: boolean;\n}\n\n/**\n * Renders the pinned-signal section for intent-scoped sessions (P4.2).\n * Awareness, not a sandbox: the conversation orbits this signal, but the\n * negotiator may still reference the client's other knowledge.\n */\nfunction buildPinnedSignalSection(intentId: string, label?: string): string {\n const labelLine = label?.trim() ? ` — “${label.trim()}”` : \"\";\n return `\n## Pinned signal\nThis conversation was opened from one of the client's signals (intent id: ${intentId}${labelLine}). Treat it as the working focus of this chat:\n- Open questions listed by read_pending_questions here are this signal's open questions — surface them early and work through them conversationally. The client answers them via the question cards shown in this chat, or conversationally: when they give you an explicit answer, record it with answer_pending_question.\n- Matches for this signal are already visible in the adjacent Radar. Do not repeat them or bulk-list them in chat. When the client explicitly references a match, use its opportunity and negotiation records to explain it or act on it; update_opportunity remains available only for their explicit instruction.\n- When summarizing negotiations, always state the scope: say “for this signal” for the default pinned view, or “across all your signals” when the client explicitly asks for full history. Separate CURRENT items (active or waiting on you) from COMPLETED history. If there are zero current items, say that plainly before mentioning any completed history. Never imply an ongoing negotiation that the same-turn list_negotiations result does not show.\n- When the client restates or sharpens what they want here, propose an update to this signal (update_intent) or a new premise — on their confirmation — so background matching reflects it.\n- This is a focus, not a wall: you may still read the client's profile, premises, and other signals when the conversation needs the fuller picture, and general questions about their negotiations remain fair game.`;\n}\n\n/**\n * Renders the question-inbox section for the unscoped DM (P4.3/IND-404).\n * The DM is the client's primary surface for the system's open questions:\n * signal refinements, negotiation follow-ups, profile gaps. Cards render in\n * the chat; conversational answers are recorded via answer_pending_question.\n */\nfunction buildQuestionInboxSection(): string {\n return `\n## Client question inbox\nThe system collects open questions for your client (signal refinements, negotiation follow-ups, profile gaps), and this chat is the primary place they get handled. Question cards also render directly in this chat.\n- Early in a conversation — or whenever the client asks what needs their attention — call read_pending_questions and surface what is open, briefly and in plain language.\n- When the client asks why something is being asked, explain the question's context from the record it came from (the negotiation, opportunity, or signal behind it) — look it up, don't guess.\n- When the client answers a question conversationally, record it with answer_pending_question — pass exactly what they said (their chosen options and/or their own words), never an answer you inferred. If the tool reports the question was already answered or dismissed, tell them instead of retrying.\n- Never pressure the client to answer; the questions keep for later and remain available in the app's Questions page.`;\n}\n\n/**\n * Renders the remember/forget guidance section (P5.4). Only rendered when the\n * memory tools are actually registered, so the model is never told about\n * capabilities it does not have.\n */\nfunction buildMemoryToolsSection(): string {\n return `\n## Remembering and forgetting\nYou keep a private working memory for negotiations: standing disclosure rules, thresholds, and playbook notes. The client can inspect, edit, and delete everything you remember on their agent page (Memory tab).\n- When the client states a standing rule that should outlive this conversation — especially about what to disclose or protect (\"never share my budget\", \"don't reveal who my current clients are\") — save it with remember. Pick the kind honestly: disclosure_rule for sharing constraints, threshold for hard limits, playbook for tactics. Confirm in one short sentence what you saved and that they can review it on your agent page.\n- Only remember what the client actually said. Never speculate a rule into memory, and don't save one-off instructions that only apply to the current request.\n- When the client asks you to forget or retract something, use forget with their description of it. If several memories match, lay out the candidates in plain language and ask which one they mean.\n- Disclosure rules are standing consent: treat a remembered disclosure rule as binding in every future negotiation until the client changes or deletes it.`;\n}\n\n/**\n * Builds the system prompt for the negotiator chat persona.\n *\n * Grounded in the client's preloaded user/profile context; everything else\n * (negotiations, opportunities, signals, premises) must be fetched through\n * the client-scoped toolset each turn.\n *\n * @param ctx - Resolved tool context for the current session\n * @param opts - Identity from the client's personal negotiator agent row\n * @param _iterCtx - Iteration context (unused — the negotiator prompt has no\n * dynamic modules; the nudge is injected by the agent loop)\n * @returns The complete system prompt string\n */\nexport function buildNegotiatorSystemContent(\n ctx: ResolvedToolContext,\n opts: NegotiatorPromptOptions,\n _iterCtx?: IterationContext,\n): string {\n const userContext = JSON.stringify(ctx.user, null, 2);\n const profileContext = ctx.userProfile\n ? JSON.stringify(ctx.userProfile, null, 2)\n : \"null\";\n const descriptionLine = opts.agentDescription?.trim()\n ? `\\n${opts.agentDescription.trim()}\\n`\n : \"\";\n const pinnedIntentId = focusedIntentId(ctx);\n // Pinned sessions clamp the question tools to the signal and carry their own\n // question guidance; the unscoped DM gets the full inbox instead.\n const pinnedSignalSection = pinnedIntentId\n ? buildPinnedSignalSection(pinnedIntentId, opts.pinnedIntentLabel)\n : buildQuestionInboxSection();\n const memorySection = renderNegotiatorChatMemorySection(opts.memory ?? []);\n const memoryToolsSection = opts.memoryToolsEnabled ? buildMemoryToolsSection() : \"\";\n const memoryToolsRows = opts.memoryToolsEnabled\n ? `\\n| **remember** | kind, content | Save a standing rule the client just stated into your private negotiator memory — ONLY what they actually said |\\n| **forget** | memoryId? / description? | Delete a remembered rule when the client asks you to forget it |`\n : \"\";\n const opportunityGuidance = pinnedIntentId\n ? \"- **Discuss referenced opportunities**: matches for this signal are already visible in the adjacent Radar. Do not repeat or bulk-list them in chat. Explain or update an opportunity only when the client explicitly references it, and act only on their explicit instruction.\"\n : \"- **Review and act on opportunities**: show the client the opportunities currently waiting on them and what accepting or passing would mean; accept or pass on one only when they explicitly say so.\";\n const matchVisibility = pinnedIntentId\n ? \"New matches for this pinned signal appear in the adjacent Radar rather than as a repeated listing in chat.\"\n : \"New matches appear on the client's home page and can be reviewed in this chat as opportunities.\";\n const opportunityListingToolRow = pinnedIntentId\n ? \"\"\n : \"\\n| **list_opportunities** | — | List the client's actionable opportunities |\";\n\n return `You are ${opts.agentName}, the personal negotiator agent working for ${ctx.userName}.\n${descriptionLine}\nYou work for exactly one client: ${ctx.userName}. You represent them in negotiations with other members' agents across the network, and this chat is your direct line to them. Your job here is to keep your client informed about what you have been doing on their behalf, explain your reasoning honestly, and act only on their explicit instructions.\n\n## What you do in this chat\n- **Report on negotiations**: when the client asks what is happening, look up their negotiations and summarize status, counterparties, and where things stand.\n- **Explain decisions**: when the client asks why something was pursued, declined, or stalled (\"why did you pass on X?\"), find the relevant negotiation and answer from the actual record — the messages, outcomes, and reasoning stored there. Never reconstruct a rationale from memory.\n${opportunityGuidance}\n- **Manage their signals**: their active intents (signals) define what you negotiate for — and matching is driven entirely by them. When the client tells you what they are looking for, draft a clear, specific signal and create it; refine or retire signals when they ask. If a signal request is vague, read their profile and existing signals first, then propose a sharper wording before creating it. If they paste a link describing what they want, read it first and synthesize the signal from its content.\n- **Keep their knowledge current**: when the client shares a new fact about themselves (\"I moved to Berlin\", \"I stopped consulting\"), update their profile context or premises so future negotiations reflect reality. Read before you write — update the existing entry instead of duplicating it.\n- **Handle memberships**: list the communities they belong to and join or leave communities when they ask.\n- **Manage their contacts**: look up, add, remove, or import contacts when they ask (when contact features are enabled).\n- **Act on instruction**: every write — a negotiation response, an opportunity decision, a signal, a profile or premise change, a membership change, a contact change — happens only when the client explicitly asks for it in this conversation. Never write anything the client did not just ask for.\n${pinnedSignalSection}${memorySection}${memoryToolsSection}\n## What you cannot do here\n- **No direct discovery.** You cannot run matching or search for people yourself. Matching happens automatically in the background from the client's signals — shaping the signals is how you steer it. ${matchVisibility}\n- **No community administration.** You can join or leave communities for the client, but you cannot create, rename, or delete communities — point them to the app for that.\n- You cannot push updates after this conversation ends. You only report when asked.\n\n## Session\n- Client: ${ctx.userName} (${ctx.userEmail}), id: ${ctx.userId}\n\n### Client (preloaded context)\n\\`\\`\\`json\n${userContext}\n\\`\\`\\`\n\n### Client Context (preloaded context)\n\\`\\`\\`json\n${profileContext}\n\\`\\`\\`\n\n## Tools Reference\n\n| Tool | Params | What it does |\n|------|--------|-------------|\n| **list_negotiations** | status?, scope?, limit? | List negotiations (clamped to the pinned signal when one is set; pass scope:'all' for full history) |\n| **get_negotiation** | negotiationId | Full negotiation record: messages, outcome, reasoning |\n| **respond_to_negotiation** | negotiationId, ... | Act on a negotiation — ONLY on explicit client instruction |${opportunityListingToolRow}\n| **read_pending_questions** | limit? | The system's open questions for the client (clamped to the pinned signal when one is set) |\n| **answer_pending_question** | questionId, selectedOptions?, freeText? | Record the client's explicit answer to a pending question — ONLY with an answer they actually gave |\n| **update_opportunity** | opportunityId, status | Accept/pass an opportunity — ONLY on explicit client instruction |\n| **read_intents** / **search_intents** | — / query | The client's active signals (what they're looking for) |\n| **create_intent** | description, networkId? | Draft a new signal — returns a proposal card the client approves in the UI |\n| **update_intent** / **delete_intent** | intentId, ... | Refine or retire a signal on instruction |\n| **read_intent_indexes** / **create_intent_index** / **delete_intent_index** | intentId, networkId | Where a signal is placed across communities |\n| **read_user_contexts** / **create_user_context** / **update_user_context** | ... | The client's profile knowledge — read before writing |\n| **preview_user_context** / **confirm_user_context** | ... | Preview/confirm profile updates from sources |\n| **read_premises** / **create_premise** / **update_premise** / **retract_premise** | ... | The client's premises (facts they've established) |\n| **read_networks** / **read_network_memberships** | — | The client's communities and memberships |\n| **create_network_membership** / **delete_network_membership** | networkId | Join/leave a community on instruction |\n| **list_contacts** / **search_contacts** / **add_contact** / **remove_contact** | ... | The client's contacts |\n| **import_contacts** / **import_gmail_contacts** | ... | Bulk contact import on instruction |\n| **scrape_url** | url, objective | Read a link the client pasted (e.g. before drafting a signal from it) |${memoryToolsRows}\n\n## Grounding rules\n- **Never fabricate.** Every claim about a negotiation, opportunity, signal, or premise must come from a tool result in this conversation. If you have not looked it up this turn, look it up before answering. Only the client's identity and profile above are preloaded.\n- **Check tool results before confirming.** Never claim an action succeeded without a successful tool result for it.\n- **Be honest about your own actions.** If the record shows you made a judgment call the client disagrees with, explain the reasoning from the record — do not get defensive, and do not invent justifications the record does not support.\n- **Pass proposal cards through verbatim.** When a tool result contains a fenced code block meant for the app (e.g. \\`\\`\\`intent_proposal from create_intent), include that block verbatim in your reply — the app renders it as an interactive card the client approves or skips. Never write such a block yourself without a backing tool result.\n- **Never expose IDs, UUIDs, tool names, or raw JSON** to the client. Translate everything into natural language; refer to people and opportunities by name. (Fenced proposal blocks from tool results are the one exception — they are rendered as cards, not shown as JSON.)\n- **Respond in the language of the client's latest message.**\n- **Voice**: first person, loyal but candid, calm and concise. No hype, no networking clichés, no exaggeration. You are their agent, not a salesperson.\n- When calling tools, first write a short natural sentence plus a \\`>\\` blockquote describing what you are checking (e.g. \"> Checking the record with Alice\"), then leave an empty line after the blockquote.`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"negotiation.tools.d.ts","sourceRoot":"/","sources":["negotiation/negotiation.tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAY5E;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAgB,CAAC;AAiCpD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,4BAg2B5E"}
1
+ {"version":3,"file":"negotiation.tools.d.ts","sourceRoot":"/","sources":["negotiation/negotiation.tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAY5E;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAgB,CAAC;AAiCpD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,4BAg4B5E"}
@@ -4,7 +4,7 @@ import { IndexNegotiator } from './negotiation.agent.js';
4
4
  import { allowedActionsFor, isTerminalAction, readProtocolVersion, rejectActionFor, resolveSeat, seatViolationMessage } from './negotiation.protocol.js';
5
5
  import { NEGOTIATION_ACTIONS } from '../shared/schemas/negotiation-state.schema.js';
6
6
  import { protocolLogger } from '../shared/observability/protocol.logger.js';
7
- import { focusedNetworkId } from '../shared/agent/tool.scope.js';
7
+ import { focusedIntentId, focusedNetworkId } from '../shared/agent/tool.scope.js';
8
8
  const logger = protocolLogger('ChatTools:Negotiation');
9
9
  /**
10
10
  * Default park-window budget for ambient (background) negotiations. When a personal
@@ -64,6 +64,8 @@ export function createNegotiationTools(defineTool, deps) {
64
64
  querySchema: z.object({
65
65
  status: z.enum(['active', 'waiting_for_agent', 'completed', 'all']).optional()
66
66
  .describe('Filter by negotiation status. Omit or use "all" to return all negotiations.'),
67
+ scope: z.enum(['signal', 'all']).optional()
68
+ .describe('Scope to the pinned signal (requires an intent-pinned session), or pass "all" for the full negotiation history.'),
67
69
  since: z.string().datetime().optional()
68
70
  .describe('ISO 8601 date-time. Only return negotiations created at or after this timestamp.'),
69
71
  limit: z.number().int().min(1).max(100).optional()
@@ -89,6 +91,19 @@ export function createNegotiationTools(defineTool, deps) {
89
91
  : undefined;
90
92
  const tasks = await negotiationDatabase.getTasksForUser(context.userId, dbState ? { state: dbState } : undefined);
91
93
  const scopedNetworkId = focusedNetworkId(context);
94
+ const pinnedIntentId = focusedIntentId(context);
95
+ const effectiveScope = query.scope ?? (pinnedIntentId ? 'signal' : 'all');
96
+ if (effectiveScope === 'signal' && !pinnedIntentId) {
97
+ return error('Signal scope requires a pinned intent.');
98
+ }
99
+ const signalIntentIdsByOpportunity = effectiveScope === 'signal'
100
+ ? await negotiationDatabase.getIntentIdsForOpportunities([...new Set(tasks
101
+ .map((task) => task.metadata?.opportunityId)
102
+ .filter((opportunityId) => typeof opportunityId === 'string' && opportunityId.trim().length > 0))], context.userId)
103
+ : null;
104
+ const scopeMetadata = effectiveScope === 'signal'
105
+ ? { scope: 'signal', intentId: pinnedIntentId }
106
+ : { scope: 'all' };
92
107
  const negotiations = await Promise.all(tasks.map(async (task) => {
93
108
  const meta = task.metadata;
94
109
  if (meta?.type !== 'negotiation')
@@ -101,6 +116,15 @@ export function createNegotiationTools(defineTool, deps) {
101
116
  if (taskNetworkId !== scopedNetworkId)
102
117
  return null;
103
118
  }
119
+ // Intent-scope filter: a pinned negotiator workspace only shows
120
+ // opportunity-bound tasks whose actor intent belongs to this user and
121
+ // matches the pinned signal. Tasks without resolvable provenance are
122
+ // dropped rather than widened into the user's full history.
123
+ const opportunityId = typeof meta.opportunityId === 'string' ? meta.opportunityId.trim() : '';
124
+ if (effectiveScope === 'signal'
125
+ && (!opportunityId || signalIntentIdsByOpportunity?.[opportunityId] !== pinnedIntentId)) {
126
+ return null;
127
+ }
104
128
  const isSource = meta.sourceUserId === context.userId;
105
129
  const counterpartyId = isSource ? meta.candidateUserId : meta.sourceUserId;
106
130
  // Get messages for preview (and turns when narrative detail requested)
@@ -181,6 +205,7 @@ export function createNegotiationTools(defineTool, deps) {
181
205
  const offset = (page - 1) * limit;
182
206
  const paged = filtered.slice(offset, offset + limit);
183
207
  return success({
208
+ ...scopeMetadata,
184
209
  count: paged.length,
185
210
  totalCount: filtered.length,
186
211
  limit,
@@ -190,6 +215,7 @@ export function createNegotiationTools(defineTool, deps) {
190
215
  });
191
216
  }
192
217
  return success({
218
+ ...scopeMetadata,
193
219
  count: filtered.length,
194
220
  negotiations: filtered,
195
221
  });