@indexnetwork/protocol 4.18.0-rc.364.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/negotiator.tools.d.ts +0 -2
- package/dist/chat/negotiator.tools.d.ts.map +1 -1
- package/dist/chat/negotiator.tools.js +0 -2
- package/dist/chat/negotiator.tools.js.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp.server.d.ts +0 -9
- package/dist/mcp/mcp.server.d.ts.map +1 -1
- package/dist/mcp/mcp.server.js +0 -9
- package/dist/mcp/mcp.server.js.map +1 -1
- package/dist/negotiation/negotiation.graph.d.ts +0 -491
- package/dist/negotiation/negotiation.graph.d.ts.map +1 -1
- package/dist/negotiation/negotiation.graph.js +0 -7
- package/dist/negotiation/negotiation.graph.js.map +1 -1
- package/dist/opportunity/discriminator/discriminator.adjustments.d.ts +0 -2
- package/dist/opportunity/discriminator/discriminator.adjustments.d.ts.map +1 -1
- package/dist/opportunity/discriminator/discriminator.adjustments.js +0 -7
- package/dist/opportunity/discriminator/discriminator.adjustments.js.map +1 -1
- package/dist/opportunity/discriminator/discriminator.env.d.ts +0 -7
- package/dist/opportunity/discriminator/discriminator.env.d.ts.map +1 -1
- package/dist/opportunity/discriminator/discriminator.env.js +0 -7
- package/dist/opportunity/discriminator/discriminator.env.js.map +1 -1
- package/dist/opportunity/discriminator/discriminator.push.d.ts +0 -2
- package/dist/opportunity/discriminator/discriminator.push.d.ts.map +1 -1
- package/dist/opportunity/discriminator/discriminator.push.js +0 -6
- package/dist/opportunity/discriminator/discriminator.push.js.map +1 -1
- package/package.json +1 -1
- package/dist/shared/agent/response.streamer.d.ts +0 -36
- package/dist/shared/agent/response.streamer.d.ts.map +0 -1
- package/dist/shared/agent/response.streamer.js +0 -46
- package/dist/shared/agent/response.streamer.js.map +0 -1
- package/dist/shared/interfaces/storage.interface.d.ts +0 -46
- package/dist/shared/interfaces/storage.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/storage.interface.js +0 -6
- package/dist/shared/interfaces/storage.interface.js.map +0 -1
|
@@ -71,13 +71,6 @@ export const POOL_ADJUSTMENT_FACTOR_OTHER = 0.6;
|
|
|
71
71
|
export const POOL_ADJUSTMENT_FACTOR_UNKNOWN = 0.9;
|
|
72
72
|
/** Floor for the cumulative adjustment multiplier — demoted, never hidden. */
|
|
73
73
|
export const POOL_ADJUSTMENT_FLOOR = 0.3;
|
|
74
|
-
/**
|
|
75
|
-
* Staleness guard (IND-419): when more than this fraction of a question's
|
|
76
|
-
* stored assignments point at opportunities that left the pool (expired /
|
|
77
|
-
* rejected / accepted / archived), skip the re-rank — the snapshot no longer
|
|
78
|
-
* describes the live pool.
|
|
79
|
-
*/
|
|
80
|
-
export const POOL_STALENESS_THRESHOLD = 0.3;
|
|
81
74
|
/** Debounce window for answer-triggered re-discovery (Tier 1), per intent. */
|
|
82
75
|
export const POOL_RERUN_DEBOUNCE_MS = 60000;
|
|
83
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.env.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,wDAAwD;AACxD,MAAM,UAAU,uBAAuB;IACrC,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;AACnF,CAAC;AAKD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACzE,CAAC;AAKD;;;GAGG;AACH,MAAM,UAAU,qBAAqB;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,IAAI,CAAC;AAEvD,uEAAuE;AACvE,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAElD,uEAAuE;AACvE,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAK9C;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5E,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEhD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAElD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAM,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAElD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAEpD,qEAAqE;AACrE,MAAM,CAAC,MAAM,2CAA2C,GAAG,GAAG,CAAC","sourcesContent":["/**\n * Centralized accessors for pool-question environment variables (IND-416).\n *\n * POOL_QUESTIONS_MINING off | shadow — P1 shadow axis mining on\n * discovery-run completion. `shadow` mines and\n * scores axes and logs them; no questions are\n * generated and no user-facing behavior changes.\n * Any value other than \"shadow\" (including unset)\n * means off.\n *\n * All reads go through this module — do not read these variables via\n * `process.env` elsewhere. Values are read on every call (no caching) so\n * tests and long-lived processes observe changes.\n */\n\n/** Mining mode for pool discriminator axes. */\nexport type PoolQuestionsMiningMode = \"off\" | \"shadow\";\n\n/** Current POOL_QUESTIONS_MINING mode (default off). */\nexport function poolQuestionsMiningMode(): PoolQuestionsMiningMode {\n return process.env.POOL_QUESTIONS_MINING?.trim() === \"shadow\" ? \"shadow\" : \"off\";\n}\n\n/** Question mode for pool discriminators (IND-418). */\nexport type PoolQuestionsMode = \"off\" | \"on\";\n\n/**\n * Current POOL_QUESTIONS_MODE (default off). When \"on\", the mining hook also\n * enqueues a pool_discovery question for the top eligible discriminator\n * (still subject to the QUESTIONER_ENABLED master gate and per-intent budget).\n * \"on\" implies mining runs even when POOL_QUESTIONS_MINING is off.\n */\nexport function poolQuestionsMode(): PoolQuestionsMode {\n return process.env.POOL_QUESTIONS_MODE?.trim() === \"on\" ? \"on\" : \"off\";\n}\n\n/** Push delivery mode for high-VoI pool questions (IND-421). */\nexport type PoolQuestionsPushMode = \"off\" | \"on\";\n\n/**\n * Current POOL_QUESTIONS_PUSH mode (default off). Callers must additionally\n * require pool-question mode and negotiator availability before delivery.\n */\nexport function poolQuestionsPushMode(): PoolQuestionsPushMode {\n return process.env.POOL_QUESTIONS_PUSH?.trim() === \"on\" ? \"on\" : \"off\";\n}\n\n/** Newborn-opportunity stamping mode (IND-420 P4b). */\nexport type PoolQuestionsStampNewbornMode = \"off\" | \"on\";\n\n/**\n * Current POOL_QUESTIONS_STAMP_NEWBORN mode (default off). Effective callers\n * additionally require {@link poolQuestionsMode} to be on.\n */\nexport function poolQuestionsStampNewborn(): PoolQuestionsStampNewbornMode {\n return process.env.POOL_QUESTIONS_STAMP_NEWBORN?.trim() === \"on\" ? \"on\" : \"off\";\n}\n\n/** Minimum VoI for a discriminator to become (or chain) a question. */\nexport const POOL_QUESTION_MIN_VOI = 0.2;\n\n/** Minimum evidence-verification rate for a discriminator to become a question. */\nexport const POOL_QUESTION_MIN_EVIDENCE_RATE = 0.6;\n\n/** Max eligible discriminators carried per mining pass (asked + alternates). */\nexport const POOL_QUESTION_MAX_DISCRIMINATORS = 3;\n\n/** Unattended budget: max pending questions of ANY mode per intent. */\nexport const POOL_QUESTION_MAX_PENDING_PER_INTENT = 3;\n\n/** Initial internal VoI threshold for proactive push delivery. */\nexport const POOL_QUESTION_PUSH_BASE_VOI = 0.6;\n\n/** Multiplicative VoI threshold increase per consecutive dismissal. */\nexport const POOL_QUESTION_PUSH_DISMISSAL_DECAY = 1.15;\n\n/** Minimum pool size for proactive delivery (stricter than mining). */\nexport const POOL_QUESTION_PUSH_MIN_POOL_SIZE = 8;\n\n/** Maximum claimed proactive pool pushes per recipient per UTC day. */\nexport const POOL_QUESTION_PUSH_DAILY_CAP = 2;\n\n/** Ranking mode for pool adjustments (IND-419). */\nexport type PoolQuestionsRankingMode = \"off\" | \"on\";\n\n/**\n * Current POOL_QUESTIONS_RANKING (default off). When \"on\", the home feed\n * orders by adjusted confidence (confidence × Π poolAdjustments.factor,\n * floor {@link POOL_ADJUSTMENT_FLOOR}). Adjustments are WRITTEN regardless of\n * this flag — it only gates whether ordering reads them, so the apply path\n * can ship first.\n */\nexport function poolQuestionsRanking(): PoolQuestionsRankingMode {\n return process.env.POOL_QUESTIONS_RANKING?.trim() === \"on\" ? \"on\" : \"off\";\n}\n\n/** Adjustment factor for candidates on the side the user did NOT choose. */\nexport const POOL_ADJUSTMENT_FACTOR_OTHER = 0.6;\n\n/** Adjustment factor for candidates the miner could not assign (unknown). */\nexport const POOL_ADJUSTMENT_FACTOR_UNKNOWN = 0.9;\n\n/** Floor for the cumulative adjustment multiplier — demoted, never hidden. */\nexport const POOL_ADJUSTMENT_FLOOR = 0.3;\n\n/** Debounce window for answer-triggered re-discovery (Tier 1), per intent. */\nexport const POOL_RERUN_DEBOUNCE_MS = 60_000;\n\n/**\n * k-anonymity floor: axes are only mined when the pool has at least this many\n * candidates, so no axis (or later, question option) can be traced back to a\n * specific individual.\n */\nexport const POOL_DISCRIMINATOR_MIN_POOL_SIZE = 5;\n\n/** Max candidates sent to the miner LLM (top-N by score). */\nexport const POOL_DISCRIMINATOR_MAX_CANDIDATES = 24;\n\n/** Max chars of public context per candidate in the miner prompt. */\nexport const POOL_DISCRIMINATOR_MAX_PUBLIC_CONTEXT_CHARS = 400;\n"]}
|
|
@@ -3,8 +3,6 @@ import type { QuestionPoolSnapshot } from "../../shared/schemas/question.schema.
|
|
|
3
3
|
export declare const POOL_QUESTION_PUSH_TITLE_MAX_CHARS = 80;
|
|
4
4
|
/** Stable identity for one pool refresh cycle. Chained alternates retain it. */
|
|
5
5
|
export declare function poolQuestionCycleKey(pool: Pick<QuestionPoolSnapshot, "runId" | "minedAt">): string;
|
|
6
|
-
/** Strict VoI threshold after the recipient's consecutive dismissal streak. */
|
|
7
|
-
export declare function poolQuestionPushThreshold(consecutiveDismissals: number): number;
|
|
8
6
|
/** Escape plain text so it cannot alter the deterministic Markdown template. */
|
|
9
7
|
export declare function escapePoolPushMarkdown(text: string): string;
|
|
10
8
|
/** Build the sole proactive user-facing DM line for a pushed pool question. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.push.d.ts","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"discriminator.push.d.ts","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,2EAA2E;AAC3E,eAAO,MAAM,kCAAkC,KAAK,CAAC;AAErD,gFAAgF;AAChF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,SAAS,CAAC,GACpD,MAAM,CAGR;AAED,gFAAgF;AAChF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,+EAA+E;AAC/E,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CAMT"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { POOL_QUESTION_PUSH_BASE_VOI, POOL_QUESTION_PUSH_DISMISSAL_DECAY } from "./discriminator.env.js";
|
|
2
1
|
/** Maximum raw intent-title characters included in a proactive DM line. */
|
|
3
2
|
export const POOL_QUESTION_PUSH_TITLE_MAX_CHARS = 80;
|
|
4
3
|
/** Stable identity for one pool refresh cycle. Chained alternates retain it. */
|
|
@@ -6,11 +5,6 @@ export function poolQuestionCycleKey(pool) {
|
|
|
6
5
|
const runId = pool.runId?.trim();
|
|
7
6
|
return runId ? `run:${runId}` : `mined:${pool.minedAt}`;
|
|
8
7
|
}
|
|
9
|
-
/** Strict VoI threshold after the recipient's consecutive dismissal streak. */
|
|
10
|
-
export function poolQuestionPushThreshold(consecutiveDismissals) {
|
|
11
|
-
const streak = Math.max(0, Math.floor(consecutiveDismissals));
|
|
12
|
-
return POOL_QUESTION_PUSH_BASE_VOI * POOL_QUESTION_PUSH_DISMISSAL_DECAY ** streak;
|
|
13
|
-
}
|
|
14
8
|
/** Escape plain text so it cannot alter the deterministic Markdown template. */
|
|
15
9
|
export function escapePoolPushMarkdown(text) {
|
|
16
10
|
return text.replace(/([\\`*_[\]{}()<>#+\-.!|])/g, "\\$1");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discriminator.push.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.push.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"discriminator.push.js","sourceRoot":"/","sources":["opportunity/discriminator/discriminator.push.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,CAAC;AAErD,gFAAgF;AAChF,MAAM,UAAU,oBAAoB,CAClC,IAAqD;IAErD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;AAC1D,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,4BAA4B,CAAC,KAI5C;IACC,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,aAAa,CAAC;IACvF,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,GAAG,kCAAkC;QAC9E,CAAC,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,kCAAkC,GAAG,CAAC,CAAC,GAAG;QACxE,CAAC,CAAC,eAAe,CAAC;IACpB,OAAO,oBAAoB,sBAAsB,CAAC,YAAY,CAAC,QAAQ,KAAK,CAAC,QAAQ,MAAM,sBAAsB,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;AAC5I,CAAC","sourcesContent":["import type { QuestionPoolSnapshot } from \"../../shared/schemas/question.schema.js\";\n\n/** Maximum raw intent-title characters included in a proactive DM line. */\nexport const POOL_QUESTION_PUSH_TITLE_MAX_CHARS = 80;\n\n/** Stable identity for one pool refresh cycle. Chained alternates retain it. */\nexport function poolQuestionCycleKey(\n pool: Pick<QuestionPoolSnapshot, \"runId\" | \"minedAt\">,\n): string {\n const runId = pool.runId?.trim();\n return runId ? `run:${runId}` : `mined:${pool.minedAt}`;\n}\n\n/** Escape plain text so it cannot alter the deterministic Markdown template. */\nexport function escapePoolPushMarkdown(text: string): string {\n return text.replace(/([\\\\`*_[\\]{}()<>#+\\-.!|])/g, \"\\\\$1\");\n}\n\n/** Build the sole proactive user-facing DM line for a pushed pool question. */\nexport function buildPoolQuestionPushMessage(input: {\n intentId: string;\n intentTitle: string;\n questionPrompt: string;\n}): string {\n const normalizedTitle = input.intentTitle.replace(/\\s+/g, \" \").trim() || \"your intent\";\n const boundedTitle = normalizedTitle.length > POOL_QUESTION_PUSH_TITLE_MAX_CHARS\n ? `${normalizedTitle.slice(0, POOL_QUESTION_PUSH_TITLE_MAX_CHARS - 1)}…`\n : normalizedTitle;\n return `Quick one about [${escapePoolPushMarkdown(boundedTitle)}](/i/${input.intentId}): ${escapePoolPushMarkdown(input.questionPrompt)}`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ChatStreamEvent } from "../../chat/chat-streaming.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Streams the final response from the chat agent.
|
|
4
|
-
*
|
|
5
|
-
* Processes the `on_chain_end` event emitted by the `agent_loop` node and
|
|
6
|
-
* yields either a token event (with the full response text) or an error event.
|
|
7
|
-
*
|
|
8
|
-
* Note on token streaming:
|
|
9
|
-
* We do NOT emit from `on_chat_model_stream` because `streamEvents` yields
|
|
10
|
-
* events from ALL model invocations, including nested ones
|
|
11
|
-
* (ExplicitIntentInferrer, SemanticVerifier, IntentReconciler, IntentIndexer)
|
|
12
|
-
* inside tools. Those emit structured JSON that must not reach the user. The
|
|
13
|
-
* chat agent uses `model.invoke()` so we don't get token-by-token streaming
|
|
14
|
-
* anyway. We only emit the clean final response from `on_chain_end`.
|
|
15
|
-
*/
|
|
16
|
-
export declare class ResponseStreamer {
|
|
17
|
-
/**
|
|
18
|
-
* Processes an `on_chain_end` event whose name is `agent_loop`.
|
|
19
|
-
*
|
|
20
|
-
* @returns An array of stream events to yield (token and/or error), plus
|
|
21
|
-
* metadata for the caller to log.
|
|
22
|
-
*/
|
|
23
|
-
handleAgentLoopEnd(sessionId: string, event: {
|
|
24
|
-
data?: {
|
|
25
|
-
output?: {
|
|
26
|
-
responseText?: string;
|
|
27
|
-
error?: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}): {
|
|
31
|
-
events: ChatStreamEvent[];
|
|
32
|
-
responseText: string;
|
|
33
|
-
hadError: boolean;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=response.streamer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response.streamer.d.ts","sourceRoot":"/","sources":["shared/agent/response.streamer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAU1E;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB;IAC3B;;;;;OAKG;IACH,kBAAkB,CAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE;gBAAE,YAAY,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,GACvE;QAAE,MAAM,EAAE,eAAe,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE;CA4B1E"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createTokenEvent, createErrorEvent } from "../../chat/chat-streaming.types.js";
|
|
2
|
-
import { protocolLogger } from "../observability/protocol.logger.js";
|
|
3
|
-
const logger = protocolLogger("ResponseStreamer");
|
|
4
|
-
// ══════════════════════════════════════════════════════════════════════════════
|
|
5
|
-
// RESPONSE STREAMER
|
|
6
|
-
// ══════════════════════════════════════════════════════════════════════════════
|
|
7
|
-
/**
|
|
8
|
-
* Streams the final response from the chat agent.
|
|
9
|
-
*
|
|
10
|
-
* Processes the `on_chain_end` event emitted by the `agent_loop` node and
|
|
11
|
-
* yields either a token event (with the full response text) or an error event.
|
|
12
|
-
*
|
|
13
|
-
* Note on token streaming:
|
|
14
|
-
* We do NOT emit from `on_chat_model_stream` because `streamEvents` yields
|
|
15
|
-
* events from ALL model invocations, including nested ones
|
|
16
|
-
* (ExplicitIntentInferrer, SemanticVerifier, IntentReconciler, IntentIndexer)
|
|
17
|
-
* inside tools. Those emit structured JSON that must not reach the user. The
|
|
18
|
-
* chat agent uses `model.invoke()` so we don't get token-by-token streaming
|
|
19
|
-
* anyway. We only emit the clean final response from `on_chain_end`.
|
|
20
|
-
*/
|
|
21
|
-
export class ResponseStreamer {
|
|
22
|
-
/**
|
|
23
|
-
* Processes an `on_chain_end` event whose name is `agent_loop`.
|
|
24
|
-
*
|
|
25
|
-
* @returns An array of stream events to yield (token and/or error), plus
|
|
26
|
-
* metadata for the caller to log.
|
|
27
|
-
*/
|
|
28
|
-
handleAgentLoopEnd(sessionId, event) {
|
|
29
|
-
const output = event.data?.output;
|
|
30
|
-
const responseText = typeof output?.responseText === "string" ? output.responseText : "";
|
|
31
|
-
const agentError = typeof output?.error === "string" ? output.error : undefined;
|
|
32
|
-
logger.debug("Agent loop output", { output, responseText, agentError });
|
|
33
|
-
const events = [];
|
|
34
|
-
if (agentError) {
|
|
35
|
-
logger.warn("Agent loop returned error", { agentError });
|
|
36
|
-
events.push(createErrorEvent(sessionId, agentError === "JSON error injected into SSE stream"
|
|
37
|
-
? "The response could not be sent correctly. Please try again."
|
|
38
|
-
: agentError, "AGENT_ERROR"));
|
|
39
|
-
}
|
|
40
|
-
if (responseText) {
|
|
41
|
-
events.push(createTokenEvent(sessionId, responseText));
|
|
42
|
-
}
|
|
43
|
-
return { events, responseText, hadError: !!agentError };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=response.streamer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response.streamer.js","sourceRoot":"/","sources":["shared/agent/response.streamer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,MAAM,MAAM,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAElD,iFAAiF;AACjF,oBAAoB;AACpB,iFAAiF;AAEjF;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;OAKG;IACH,kBAAkB,CAChB,SAAiB,EACjB,KAAwE;QAExE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;QAClC,MAAM,YAAY,GAAG,OAAO,MAAM,EAAE,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,MAAM,UAAU,GAAG,OAAO,MAAM,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAEhF,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;QAExE,MAAM,MAAM,GAAsB,EAAE,CAAC;QAErC,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;YACzD,MAAM,CAAC,IAAI,CACT,gBAAgB,CACd,SAAS,EACT,UAAU,KAAK,qCAAqC;gBAClD,CAAC,CAAC,6DAA6D;gBAC/D,CAAC,CAAC,UAAU,EACd,aAAa,CACd,CACF,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import type { ChatStreamEvent } from \"../../chat/chat-streaming.types.js\";\nimport { createTokenEvent, createErrorEvent } from \"../../chat/chat-streaming.types.js\";\nimport { protocolLogger } from \"../observability/protocol.logger.js\";\n\nconst logger = protocolLogger(\"ResponseStreamer\");\n\n// ══════════════════════════════════════════════════════════════════════════════\n// RESPONSE STREAMER\n// ══════════════════════════════════════════════════════════════════════════════\n\n/**\n * Streams the final response from the chat agent.\n *\n * Processes the `on_chain_end` event emitted by the `agent_loop` node and\n * yields either a token event (with the full response text) or an error event.\n *\n * Note on token streaming:\n * We do NOT emit from `on_chat_model_stream` because `streamEvents` yields\n * events from ALL model invocations, including nested ones\n * (ExplicitIntentInferrer, SemanticVerifier, IntentReconciler, IntentIndexer)\n * inside tools. Those emit structured JSON that must not reach the user. The\n * chat agent uses `model.invoke()` so we don't get token-by-token streaming\n * anyway. We only emit the clean final response from `on_chain_end`.\n */\nexport class ResponseStreamer {\n /**\n * Processes an `on_chain_end` event whose name is `agent_loop`.\n *\n * @returns An array of stream events to yield (token and/or error), plus\n * metadata for the caller to log.\n */\n handleAgentLoopEnd(\n sessionId: string,\n event: { data?: { output?: { responseText?: string; error?: string } } }\n ): { events: ChatStreamEvent[]; responseText: string; hadError: boolean } {\n const output = event.data?.output;\n const responseText = typeof output?.responseText === \"string\" ? output.responseText : \"\";\n const agentError = typeof output?.error === \"string\" ? output.error : undefined;\n\n logger.debug(\"Agent loop output\", { output, responseText, agentError });\n\n const events: ChatStreamEvent[] = [];\n\n if (agentError) {\n logger.warn(\"Agent loop returned error\", { agentError });\n events.push(\n createErrorEvent(\n sessionId,\n agentError === \"JSON error injected into SSE stream\"\n ? \"The response could not be sent correctly. Please try again.\"\n : agentError,\n \"AGENT_ERROR\"\n )\n );\n }\n\n if (responseText) {\n events.push(createTokenEvent(sessionId, responseText));\n }\n\n return { events, responseText, hadError: !!agentError };\n }\n}\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage interface for protocol layer (file uploads, avatars).
|
|
3
|
-
* Implementations live in src/adapters (e.g. S3).
|
|
4
|
-
*/
|
|
5
|
-
export interface Storage {
|
|
6
|
-
/**
|
|
7
|
-
* Upload a buffer to storage.
|
|
8
|
-
* @param buffer - The file contents
|
|
9
|
-
* @param key - The storage object key (path)
|
|
10
|
-
* @param contentType - The MIME type
|
|
11
|
-
* @returns The URL to access the file
|
|
12
|
-
*/
|
|
13
|
-
uploadBuffer(buffer: Buffer, key: string, contentType: string): Promise<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Upload an avatar image to storage.
|
|
16
|
-
* @param buffer - The image buffer
|
|
17
|
-
* @param userId - The user's ID
|
|
18
|
-
* @param extension - File extension (e.g., "png", "jpg")
|
|
19
|
-
* @param contentType - The MIME type
|
|
20
|
-
* @returns The URL to access the avatar
|
|
21
|
-
*/
|
|
22
|
-
uploadAvatar(buffer: Buffer, userId: string, extension: string, contentType: string): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* Upload an index (network) image to storage.
|
|
25
|
-
* @param buffer - The image buffer
|
|
26
|
-
* @param userId - The user's ID
|
|
27
|
-
* @param extension - File extension (e.g., "png", "jpg")
|
|
28
|
-
* @param contentType - The MIME type
|
|
29
|
-
* @returns The URL to access the image
|
|
30
|
-
*/
|
|
31
|
-
uploadIndexImage(buffer: Buffer, userId: string, extension: string, contentType: string): Promise<string>;
|
|
32
|
-
/**
|
|
33
|
-
* Upload a base64-encoded image to storage.
|
|
34
|
-
* @param base64Image - The base64 string (can include data URI prefix)
|
|
35
|
-
* @param folder - The folder path in the bucket (default: "feedback")
|
|
36
|
-
* @returns The URL to access the image
|
|
37
|
-
*/
|
|
38
|
-
uploadBase64Image(base64Image: string, folder?: string): Promise<string>;
|
|
39
|
-
/**
|
|
40
|
-
* Generate the URL for a given storage key.
|
|
41
|
-
* @param key - The storage object key
|
|
42
|
-
* @returns The URL to access the file
|
|
43
|
-
*/
|
|
44
|
-
getUrl(key: string): string;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=storage.interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/storage.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhF;;;;;;;OAOG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtG;;;;;;;OAOG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1G;;;;;OAKG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzE;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.interface.js","sourceRoot":"/","sources":["shared/interfaces/storage.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * Storage interface for protocol layer (file uploads, avatars).\n * Implementations live in src/adapters (e.g. S3).\n */\n\nexport interface Storage {\n /**\n * Upload a buffer to storage.\n * @param buffer - The file contents\n * @param key - The storage object key (path)\n * @param contentType - The MIME type\n * @returns The URL to access the file\n */\n uploadBuffer(buffer: Buffer, key: string, contentType: string): Promise<string>;\n\n /**\n * Upload an avatar image to storage.\n * @param buffer - The image buffer\n * @param userId - The user's ID\n * @param extension - File extension (e.g., \"png\", \"jpg\")\n * @param contentType - The MIME type\n * @returns The URL to access the avatar\n */\n uploadAvatar(buffer: Buffer, userId: string, extension: string, contentType: string): Promise<string>;\n\n /**\n * Upload an index (network) image to storage.\n * @param buffer - The image buffer\n * @param userId - The user's ID\n * @param extension - File extension (e.g., \"png\", \"jpg\")\n * @param contentType - The MIME type\n * @returns The URL to access the image\n */\n uploadIndexImage(buffer: Buffer, userId: string, extension: string, contentType: string): Promise<string>;\n\n /**\n * Upload a base64-encoded image to storage.\n * @param base64Image - The base64 string (can include data URI prefix)\n * @param folder - The folder path in the bucket (default: \"feedback\")\n * @returns The URL to access the image\n */\n uploadBase64Image(base64Image: string, folder?: string): Promise<string>;\n\n /**\n * Generate the URL for a given storage key.\n * @param key - The storage object key\n * @returns The URL to access the file\n */\n getUrl(key: string): string;\n}\n"]}
|