@geminixiang/mikan 1.0.0-beta.74 → 1.0.0-beta.76
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 +17 -0
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +1 -3
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/task-intent.d.ts.map +1 -1
- package/dist/adapters/slack/task-intent.js +1 -1
- package/dist/adapters/slack/task-intent.js.map +1 -1
- package/dist/adapters/slack/tools/blockkit.d.ts +1 -0
- package/dist/adapters/slack/tools/blockkit.d.ts.map +1 -1
- package/dist/adapters/slack/tools/blockkit.js +1 -0
- package/dist/adapters/slack/tools/blockkit.js.map +1 -1
- package/dist/harness/jev.d.ts +10 -1
- package/dist/harness/jev.d.ts.map +1 -1
- package/dist/harness/jev.js +17 -1
- package/dist/harness/jev.js.map +1 -1
- package/dist/harness/presenter.d.ts.map +1 -1
- package/dist/harness/presenter.js +8 -3
- package/dist/harness/presenter.js.map +1 -1
- package/dist/harness/tools/generate-image.d.ts +1 -0
- package/dist/harness/tools/generate-image.d.ts.map +1 -1
- package/dist/harness/tools/generate-image.js +1 -0
- package/dist/harness/tools/generate-image.js.map +1 -1
- package/dist/harness/tools/host-fn-tool.d.ts +10 -1
- package/dist/harness/tools/host-fn-tool.d.ts.map +1 -1
- package/dist/harness/tools/host-fn-tool.js +22 -2
- package/dist/harness/tools/host-fn-tool.js.map +1 -1
- package/dist/harness/tools/index.d.ts.map +1 -1
- package/dist/harness/tools/index.js +6 -0
- package/dist/harness/tools/index.js.map +1 -1
- package/dist/harness/tools/jev-browser.d.ts +130 -0
- package/dist/harness/tools/jev-browser.d.ts.map +1 -0
- package/dist/harness/tools/jev-browser.js +434 -0
- package/dist/harness/tools/jev-browser.js.map +1 -0
- package/dist/harness/tools/jev.d.ts.map +1 -1
- package/dist/harness/tools/jev.js +1 -0
- package/dist/harness/tools/jev.js.map +1 -1
- package/dist/harness/tools/sandbox.d.ts +1 -0
- package/dist/harness/tools/sandbox.d.ts.map +1 -1
- package/dist/harness/tools/sandbox.js +1 -0
- package/dist/harness/tools/sandbox.js.map +1 -1
- package/dist/observability/index.d.ts +11 -2
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +30 -0
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/sentry.d.ts +9 -2
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +28 -0
- package/dist/observability/sentry.js.map +1 -1
- package/dist/observability/types.d.ts +15 -0
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-intent.d.ts","sourceRoot":"","sources":["../../../src/adapters/slack/task-intent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAG1B;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAWxD,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACrE,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GACA,MAAM,CA0BR;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,GACzD,OAAO,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"task-intent.d.ts","sourceRoot":"","sources":["../../../src/adapters/slack/task-intent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAG1B;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAWxD,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACrE,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GACA,MAAM,CA0BR;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,GACzD,OAAO,CAAC,UAAU,CAAC,CAqCrB"}
|
|
@@ -48,7 +48,7 @@ export async function classifyTaskIntent(state, text, context) {
|
|
|
48
48
|
instructions: "Given the tasks in play and the recent conversation, what does the NEW message mean?",
|
|
49
49
|
criteria: TASK_INTENT_CRITERIA,
|
|
50
50
|
},
|
|
51
|
-
});
|
|
51
|
+
}, { caller: "task_intent" });
|
|
52
52
|
const choice = result.answers.intent.choice;
|
|
53
53
|
const probabilities = result.answers.intent.probabilities;
|
|
54
54
|
log.logInfo(`[${context.conversationId}] jev task intent: ${choice}${probabilities ? ` ${JSON.stringify(probabilities)}` : ""} text="${text.slice(0, 80)}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-intent.js","sourceRoot":"","sources":["../../../src/adapters/slack/task-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAEhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAUxD,MAAM,oBAAoB,GAAG;IAC3B,MAAM,EACJ,yLAAyL;IAC3L,KAAK,EACH,6NAA6N;IAC/N,OAAO,EACL,iIAAiI;CAC3H,CAAC;AAEX,uGAAuG;AACvG,MAAM,UAAU,oBAAoB,CAClC,eAAuB,EACvB,KAAqE,EACrE,OAKC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;IAC9F,MAAM,MAAM,GAAG,eAAe,CAAC,eAAe,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM;QAChC,CAAC,CAAC,OAAO,CAAC,KAAK;aACV,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CAC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ACvB,OAAO,EAAE,uBAAuB;gBAChC,SAAS,EAAE,UAAU;gBACrB,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE;aACpD,CAAC,CAAC;QACL,CAAC;QACD,OAAO,QAAQ,EAAE,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["import { evaluateWithJev, JevNotConfiguredError } from \"../../harness/index.js\";\nimport { reportUserFacingError } from \"../../observability/index.js\";\nimport * as log from \"../../log.js\";\nimport type { TaskStatus } from \"../../types.js\";\nimport {\n formatRecentScope,\n humanizeMentions,\n readRecentScope,\n type SlackNameResolver,\n} from \"./jev-context.js\";\nimport { isTaskStatusQuestion } from \"./task-status.js\";\n\n/**\n * What a DM message means while a task is around:\n * - `status`: a pure progress question, answered from observation without a model turn\n * - `steer`: a supplement or correction for the running work, folded into its next step\n * - `request`: anything else, handled as an ordinary conversation turn\n */\nexport type TaskIntent = \"status\" | \"steer\" | \"request\";\n\nconst TASK_INTENT_CRITERIA = {\n status:\n \"Only asks whether the ongoing work is done, how it is going, what step it is on, or how long it will take. Contains no new instruction, constraint, correction, or request for content.\",\n steer:\n \"Adds information, a constraint, a correction, or a change of direction for the ongoing work while it continues (e.g. 先不要部署, also check the staging config, use the other branch). May be combined with a progress question.\",\n request:\n \"A new standalone question or request unrelated to steering the ongoing work, a reaction to a finished result, or anything else.\",\n} as const;\n\n/** The shared `state` Jev scores: the scope's recent lines, the tasks in play, and the new message. */\nexport function buildTaskIntentState(\n conversationDir: string,\n event: { ts: string; thread_ts?: string; user: string; text: string },\n options: {\n speaker?: string;\n tasks: TaskStatus[];\n resolveName?: SlackNameResolver;\n botUserId?: string | null;\n },\n): string {\n const resolve = options.resolveName ?? (() => undefined);\n const humanize = (text: string) => humanizeMentions(text, resolve, options.botUserId ?? null);\n const recent = readRecentScope(conversationDir, event, { humanize });\n const tasks = options.tasks.length\n ? options.tasks\n .map(\n (t) =>\n `- ${t.status}${t.currentTool ? ` (currently: ${t.currentTool})` : \"\"}: ${t.acknowledgement}`,\n )\n .join(\"\\n\")\n : \"(none)\";\n return [\n event.thread_ts\n ? \"Slack DM reply inside a background task thread.\"\n : \"Slack DM top-level message while background tasks exist.\",\n \"\",\n \"Tasks in this DM (most recent first):\",\n tasks,\n \"\",\n \"Recent messages in this scope (oldest first):\",\n formatRecentScope(recent),\n \"\",\n `NEW message from ${options.speaker ?? event.user}:`,\n humanize(event.text),\n ].join(\"\\n\");\n}\n\n/**\n * Classify with Jev. When Jev is unavailable or fails, reproduce the pre-Jev\n * behavior exactly: the regex shortcut decides `status`, and other text is\n * `steer` inside a task thread (where it always targeted that task) or\n * `request` at top level.\n */\nexport async function classifyTaskIntent(\n state: string,\n text: string,\n context: { conversationId: string; inTaskThread: boolean },\n): Promise<TaskIntent> {\n const fallback = (): TaskIntent =>\n isTaskStatusQuestion(text) ? \"status\" : context.inTaskThread ? \"steer\" : \"request\";\n try {\n const result = await evaluateWithJev(\n state,\n {\n intent: {\n type: \"choice\",\n instructions:\n \"Given the tasks in play and the recent conversation, what does the NEW message mean?\",\n criteria: TASK_INTENT_CRITERIA,\n },\n },\n { caller: \"task_intent\" },\n );\n const choice = result.answers.intent.choice;\n const probabilities = result.answers.intent.probabilities;\n log.logInfo(\n `[${context.conversationId}] jev task intent: ${choice}${\n probabilities ? ` ${JSON.stringify(probabilities)}` : \"\"\n } text=\"${text.slice(0, 80)}\"`,\n );\n if (choice === \"status\" || choice === \"steer\" || choice === \"request\") return choice;\n return fallback();\n } catch (err) {\n if (!(err instanceof JevNotConfiguredError)) {\n reportUserFacingError(err, {\n domain: \"chat_platform\",\n surface: \"slack_task_intent_jev\",\n operation: \"evaluate\",\n severity: \"warning\",\n context: { conversationId: context.conversationId },\n });\n }\n return fallback();\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
|
2
2
|
export type { SlackBlockKitOps } from "../types.js";
|
|
3
3
|
import type { SlackBlockKitOps } from "../types.js";
|
|
4
4
|
declare const blockkitSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
label: import("@sinclair/typebox").TString;
|
|
5
6
|
blocks: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>;
|
|
6
7
|
text: import("@sinclair/typebox").TString;
|
|
7
8
|
thread_ts: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockkit.d.ts","sourceRoot":"","sources":["../../../../src/adapters/slack/tools/blockkit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,QAAA,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"blockkit.d.ts","sourceRoot":"","sources":["../../../../src/adapters/slack/tools/blockkit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,QAAA,MAAM,cAAc;;;;;;EAqBlB,CAAC;AAyCH,wBAAgB,uBAAuB,IAAI;IACzC,IAAI,EAAE,SAAS,CAAC,OAAO,cAAc,CAAC,CAAC;IACvC,mBAAmB,EAAE,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7D,CAsEA"}
|
|
@@ -3,6 +3,7 @@ import { Type } from "@sinclair/typebox";
|
|
|
3
3
|
const MAX_BLOCKS = 50;
|
|
4
4
|
const MAX_ARGUMENT_BYTES = 64 * 1024;
|
|
5
5
|
const blockkitSchema = Type.Object({
|
|
6
|
+
label: Type.String({ description: "Brief description of this action (shown to user)" }),
|
|
6
7
|
blocks: Type.Array(Type.Unknown(), {
|
|
7
8
|
maxItems: MAX_BLOCKS,
|
|
8
9
|
description: `Slack Block Kit blocks (max ${MAX_BLOCKS}). Use {type:'markdown', text} for prose, {type:'table'} for tables, and actions/section blocks for buttons and select menus.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockkit.js","sourceRoot":"","sources":["../../../../src/adapters/slack/tools/blockkit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAIzC,kFAAkF;AAClF,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAErC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;QACjC,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,+BAA+B,UAAU,+HAA+H;KACtL,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QAChB,WAAW,EAAE,+DAA+D;KAC7E,CAAC;IACF,SAAS,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,6FAA6F;KAChG,CAAC,CACH;IACD,SAAS,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,MAAM,CAAC;QACV,WAAW,EACT,yGAAyG;KAC5G,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,SAAS,sBAAsB,CAAC,IAAa;IAC3C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnD,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACrE,IAA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@earendil-works/pi-agent-core\";\nimport { Type } from \"@sinclair/typebox\";\nexport type { SlackBlockKitOps } from \"../types.js\";\nimport type { SlackBlockKitOps } from \"../types.js\";\n\n/** Slack's own ceilings: 50 blocks per message, and a payload well under 64KB. */\nconst MAX_BLOCKS = 50;\nconst MAX_ARGUMENT_BYTES = 64 * 1024;\n\nconst blockkitSchema = Type.Object({\n label: Type.String({ description: \"Brief description of this action (shown to user)\" }),\n blocks: Type.Array(Type.Unknown(), {\n maxItems: MAX_BLOCKS,\n description: `Slack Block Kit blocks (max ${MAX_BLOCKS}). Use {type:'markdown', text} for prose, {type:'table'} for tables, and actions/section blocks for buttons and select menus.`,\n }),\n text: Type.String({\n description: \"Plain-text fallback shown in notifications and screen readers\",\n }),\n thread_ts: Type.Optional(\n Type.String({\n description:\n \"Optional active-thread TS. Posts are always constrained to the current conversation thread.\",\n }),\n ),\n update_ts: Type.Optional(\n Type.String({\n description:\n \"Update a message previously posted by slack_blockkit in this conversation instead of posting a new one.\",\n }),\n ),\n});\n\n/**\n * Reject a runaway payload before schema validation sees it.\n *\n * `prepareArguments` runs ahead of validation, which reports a failure by\n * embedding the entire argument object in its message. A malformed multi-\n * hundred-KB `blocks` array therefore lands in the session twice — once as the\n * call, once echoed back as the result — and every later reader pays for it.\n * Only a bounded result belongs there, so the size complaint stays short and\n * never quotes what it rejected.\n */\nfunction guardBlockKitArguments(args: unknown): unknown {\n if (!args || typeof args !== \"object\") return args;\n const bytes = Buffer.byteLength(JSON.stringify(args) ?? \"\", \"utf-8\");\n if (bytes > MAX_ARGUMENT_BYTES) {\n throw new Error(\n `slack_blockkit arguments are ${Math.round(bytes / 1024)}KB, over the ${MAX_ARGUMENT_BYTES / 1024}KB limit. ` +\n \"Post a short message and attach the long content as a file instead.\",\n );\n }\n const blocks = (args as { blocks?: unknown }).blocks;\n if (Array.isArray(blocks) && blocks.length > MAX_BLOCKS) {\n throw new Error(`slack_blockkit accepts at most ${MAX_BLOCKS} blocks, got ${blocks.length}.`);\n }\n return args;\n}\n\nfunction formatSlackApiError(err: unknown): Error {\n const data = (\n err as { data?: { error?: string; response_metadata?: { messages?: string[] } } } | undefined\n )?.data;\n if (!data?.error) return err instanceof Error ? err : new Error(String(err));\n const details = data.response_metadata?.messages?.length\n ? `\\n${data.response_metadata.messages.join(\"\\n\")}`\n : \"\";\n return new Error(\n `Slack rejected the request: ${data.error}${details}\\nFix the blocks JSON and retry.`,\n );\n}\n\nexport function createSlackBlockKitTool(): {\n tool: AgentTool<typeof blockkitSchema>;\n setSlackBlockKitOps: (ops: SlackBlockKitOps | null) => void;\n} {\n let boundOps: SlackBlockKitOps | null = null;\n\n const tool: AgentTool<typeof blockkitSchema> = {\n name: \"slack_blockkit\",\n label: \"slack_blockkit\",\n description:\n \"Post an interactive Slack Block Kit message (buttons, select menus, custom layouts) to the current conversation, or update one previously posted with this tool. Normal replies already render Markdown — use this only when you need interactive elements or a layout Markdown cannot express. When a user clicks a button or picks an option, you receive a new message '[Slack action] <action_id>: <value>' — choose descriptive action_ids and values so the interaction tells you what to do. Returns the message ts; pass it back as update_ts to edit the message later (e.g. refreshing vote tallies). After handling an interaction, update the message via update_ts to replace the buttons with the outcome (e.g. '✅ approved') — buttons stay clickable otherwise and repeated clicks re-trigger the action. If Slack rejects the blocks, the error includes its validation messages — fix the JSON and retry.\",\n parameters: blockkitSchema,\n prepareArguments: guardBlockKitArguments as (args: unknown) => typeof blockkitSchema.static,\n execute: async (\n _toolCallId: string,\n {\n blocks,\n text,\n thread_ts,\n update_ts,\n }: {\n blocks: unknown[];\n text: string;\n thread_ts?: string;\n update_ts?: string;\n label?: string;\n },\n signal?: AbortSignal,\n ) => {\n const ops = boundOps;\n if (!ops) {\n throw new Error(\"slack_blockkit is only available in Slack conversations\");\n }\n if (signal?.aborted) {\n throw new Error(\"Operation aborted\");\n }\n\n try {\n if (update_ts) {\n await ops.updateBlocks({ ts: update_ts, text, blocks: blocks as object[] });\n return {\n content: [\n { type: \"text\" as const, text: `Updated Block Kit message (ts: ${update_ts}).` },\n ],\n details: undefined,\n };\n }\n const { ts } = await ops.postBlocks({\n text,\n blocks: blocks as object[],\n threadTs: thread_ts,\n });\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Posted Block Kit message (ts: ${ts}). Interactive elements will arrive as \"[Slack action] <action_id>: <value>\" messages; pass ts back as update_ts to edit this message.`,\n },\n ],\n details: undefined,\n };\n } catch (err) {\n throw formatSlackApiError(err);\n }\n },\n };\n\n return {\n tool,\n setSlackBlockKitOps: (ops) => {\n boundOps = ops;\n },\n };\n}\n"]}
|
package/dist/harness/jev.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type JevCaller } from "../observability/index.js";
|
|
1
2
|
/** The current public Jev model id on OpenRouter. */
|
|
2
3
|
export declare const JEV_MODEL_ID = "~typesafe/jev-latest";
|
|
3
4
|
/**
|
|
@@ -74,6 +75,14 @@ export interface EvaluateWithJevOptions {
|
|
|
74
75
|
model?: string;
|
|
75
76
|
abortSignal?: AbortSignal;
|
|
76
77
|
headers?: Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Which call site is asking, so Jev spend is attributable in Sentry/OTel
|
|
80
|
+
* (`agent.jev.cost`, tagged `caller`) without any judged content leaving
|
|
81
|
+
* this function. Required rather than defaulted so a new call site must
|
|
82
|
+
* consciously pick an attribution instead of spend silently landing in a
|
|
83
|
+
* generic bucket.
|
|
84
|
+
*/
|
|
85
|
+
caller: JevCaller;
|
|
77
86
|
}
|
|
78
87
|
/**
|
|
79
88
|
* Evaluate one or more typed questions against a shared `state` using Jev,
|
|
@@ -82,5 +91,5 @@ export interface EvaluateWithJevOptions {
|
|
|
82
91
|
* single request; batching questions here is cheap (they share the input)
|
|
83
92
|
* and is preferred over separate calls per question.
|
|
84
93
|
*/
|
|
85
|
-
export declare function evaluateWithJev<const QUESTIONS extends JevQuestions>(state: JevEntry, questions: QUESTIONS, options
|
|
94
|
+
export declare function evaluateWithJev<const QUESTIONS extends JevQuestions>(state: JevEntry, questions: QUESTIONS, options: EvaluateWithJevOptions): Promise<JevResult<QUESTIONS>>;
|
|
86
95
|
//# sourceMappingURL=jev.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jev.d.ts","sourceRoot":"","sources":["../../src/harness/jev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jev.d.ts","sourceRoot":"","sources":["../../src/harness/jev.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE7E,qDAAqD;AACrD,eAAO,MAAM,YAAY,yBAAyB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,QAAQ,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAEnG,6FAA6F;AAC7F,MAAM,MAAM,WAAW,GACnB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,QAAQ,CAAC;IACvB,sDAAsD;IACtD,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,KAAK,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC;CAClD,GACD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,YAAY,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEvD,MAAM,MAAM,SAAS,CAAC,QAAQ,SAAS,WAAW,IAAI,QAAQ,SAAS;IAAE,I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IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;;;OAMG;IACH,MAAM,EAAE,SAAS,CAAC;CACnB;AA6ED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,KAAK,CAAC,SAAS,SAAS,YAAY,EACxE,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAuE/B"}
|
package/dist/harness/jev.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { createBuiltinJevModels, JevAPIError, JevAuthError, JevConfigError, JevConnectionError, JevResponseError, JevTimeoutError, } from "@geminixiang/jev";
|
|
26
26
|
import { readEnv } from "../env-manifest.js";
|
|
27
|
+
import { recordJevOutcome } from "../observability/index.js";
|
|
27
28
|
/** The current public Jev model id on OpenRouter. */
|
|
28
29
|
export const JEV_MODEL_ID = "~typesafe/jev-latest";
|
|
29
30
|
/** Thrown when no Jev backend has a usable credential. Callers fail closed on this. */
|
|
@@ -114,7 +115,7 @@ function fromGeminixiangAnswer(answer) {
|
|
|
114
115
|
* single request; batching questions here is cheap (they share the input)
|
|
115
116
|
* and is preferred over separate calls per question.
|
|
116
117
|
*/
|
|
117
|
-
export async function evaluateWithJev(state, questions, options
|
|
118
|
+
export async function evaluateWithJev(state, questions, options) {
|
|
118
119
|
const catalogModel = models().getModel("openrouter", "jev-latest");
|
|
119
120
|
if (!catalogModel)
|
|
120
121
|
throw new JevNotConfiguredError();
|
|
@@ -126,6 +127,7 @@ export async function evaluateWithJev(state, questions, options = {}) {
|
|
|
126
127
|
for (const [id, question] of Object.entries(questions)) {
|
|
127
128
|
wireQuestions[id] = toGeminixiangQuestion(question);
|
|
128
129
|
}
|
|
130
|
+
const startedAt = Date.now();
|
|
129
131
|
let result;
|
|
130
132
|
try {
|
|
131
133
|
result = await models().evaluate(model, { state: state, questions: wireQuestions }, {
|
|
@@ -134,6 +136,12 @@ export async function evaluateWithJev(state, questions, options = {}) {
|
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
catch (error) {
|
|
139
|
+
recordJevOutcome({
|
|
140
|
+
caller: options.caller,
|
|
141
|
+
status: "error",
|
|
142
|
+
errorType: error instanceof Error ? error.name : "Error",
|
|
143
|
+
durationMs: Date.now() - startedAt,
|
|
144
|
+
});
|
|
137
145
|
if (error instanceof JevAuthError || error instanceof JevConfigError) {
|
|
138
146
|
throw new JevNotConfiguredError();
|
|
139
147
|
}
|
|
@@ -147,6 +155,14 @@ export async function evaluateWithJev(state, questions, options = {}) {
|
|
|
147
155
|
}
|
|
148
156
|
throw error;
|
|
149
157
|
}
|
|
158
|
+
recordJevOutcome({
|
|
159
|
+
caller: options.caller,
|
|
160
|
+
status: "ok",
|
|
161
|
+
inputTokens: result.usage.input,
|
|
162
|
+
outputTokens: result.usage.output,
|
|
163
|
+
costUsd: result.usage.cost.total,
|
|
164
|
+
durationMs: Date.now() - startedAt,
|
|
165
|
+
});
|
|
150
166
|
const answers = {};
|
|
151
167
|
for (const id of Object.keys(questions)) {
|
|
152
168
|
const answer = result.answers[id];
|
package/dist/harness/jev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jev.js","sourceRoot":"","sources":["../../src/harness/jev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAIhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC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;YACjC,KAAK,YAAY,kBAAkB;YACnC,KAAK,YAAY,eAAe,EAChC,CAAC;YACD,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,EAA2D,CAAC;IAC5E,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,eAAe,CAAC,oCAAoC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACtF,OAAkD,CAAC,EAAE,CAAC,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO;QACL,OAAO;QACP,KAAK,EAAE;YACL,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;YAC/B,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;YACjC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;SAC9B;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Jev (typesafe/jev) client, backed by `@geminixiang/jev`.\n *\n * Jev is a \"System One\" evaluation model: it scores a shared `state`\n * against typed questions (a yes/no probability, a multiple choice, or a\n * position on an ordered scale) and returns calibrated probabilities. It\n * does not generate text or tool calls, so it cannot be driven through\n * pi-ai's `Provider`/`Model`/`stream()` contract the way every model\n * `models.ts` catalogs is — that contract is chat/completion shaped\n * (system prompt + messages in, streamed text/tool-call events out), and\n * Jev's typed-decision shape does not fit it. Jev is therefore not a\n * selectable chat provider: callers import `evaluateWithJev` directly at\n * whatever call site wants a fast, cheap, type-safe decision (e.g.\n * classification, routing, guardrails), and interpret the returned\n * probabilities themselves.\n *\n * `@geminixiang/jev` owns the wire protocol, provider catalog, and auth\n * resolution for four backends (TypeSafe, OpenRouter, Vercel AI Gateway,\n * Cloudflare Workers AI); this module picks OpenRouter (the same key\n * pi-ai's `openrouter` chat provider reads) and adapts its typed\n * request/answer shapes to the caller-facing contract mikan's call sites\n * already depend on, so this file is the only one that needs to know a\n * dependency swap happened.\n */\nimport {\n createBuiltinJevModels,\n JevAPIError,\n JevAuthError,\n JevConfigError,\n JevConnectionError,\n JevResponseError,\n JevTimeoutError,\n type AnswerFor as GeminixiangAnswerFor,\n type Entry as GeminixiangEntry,\n type Question as GeminixiangQuestion,\n} from \"@geminixiang/jev\";\nimport type { AuthContext } from \"@earendil-works/pi-ai\";\nimport { readEnv } from \"../env-manifest.js\";\n\n/** The current public Jev model id on OpenRouter. */\nexport const JEV_MODEL_ID = \"~typesafe/jev-latest\";\n\n/**\n * Any value Jev accepts as text-bearing structure: a string, a JSON object,\n * an array, or `null`. State, instructions, and criteria descriptions all\n * take this shape; Jev is trained to read the structure, so objects with\n * labelled keys are preferred over string templates.\n */\nexport type JevEntry = string | number | boolean | null | JevEntry[] | { [key: string]: JevEntry };\n\n/** A shared caller-facing question shape; translated to `@geminixiang/jev`'s shape below. */\nexport type JevQuestion =\n | {\n type: \"boolean\";\n instructions: JevEntry;\n /** Optional descriptions of the yes / no outcomes. */\n criteria?: { true?: JevEntry; false?: JevEntry };\n }\n | { type: \"choice\"; instructions: JevEntry; criteria: Record<string, JevEntry> }\n | { type: \"score\"; instructions: JevEntry; criteria: readonly JevEntry[] };\n\nexport type JevQuestions = Record<string, JevQuestion>;\n\nexport type JevAnswer<QUESTION extends JevQuestion> = QUESTION extends { type: \"choice\" }\n ? {\n type: \"choice\";\n choice: string;\n probabilities?: Record<string, number>;\n /** 0-1 statistic over `probabilities`; low means no option clearly fits. */\n confidence?: number;\n }\n : QUESTION extends { type: \"score\" }\n ? {\n type: \"score\";\n /** Expected level index; fractional between levels. */\n score: number;\n probabilities?: Record<string, number>;\n /** Level index -> criterion text, as echoed by Jev. */\n legend?: Record<string, string>;\n confidence?: number;\n }\n : { type: \"boolean\"; probability: number };\n\nexport interface JevResult<QUESTIONS extends JevQuestions> {\n readonly answers: { [ID in keyof QUESTIONS]: JevAnswer<QUESTIONS[ID]> };\n readonly usage: {\n inputTokens: number | undefined;\n outputTokens: number | undefined;\n cost: number | undefined;\n };\n readonly model: string;\n}\n\n/** Thrown when no Jev backend has a usable credential. Callers fail closed on this. */\nexport class JevNotConfiguredError extends Error {\n constructor() {\n super(\n \"Jev requires OPENROUTER_API_KEY (an OpenRouter API key). Set it in the environment before calling evaluateWithJev().\",\n );\n this.name = \"JevNotConfiguredError\";\n }\n}\n\nexport class JevRequestError extends Error {\n constructor(\n message: string,\n public readonly status: number,\n ) {\n super(message);\n this.name = \"JevRequestError\";\n }\n}\n\nexport interface EvaluateWithJevOptions {\n /** Evaluation model id; defaults to the current public Jev model. */\n model?: string;\n abortSignal?: AbortSignal;\n headers?: Record<string, string>;\n}\n\n// ── @geminixiang/jev wiring ──────────────────────────────────────────────\n\n/**\n * Routes env reads through `readEnv` so `MIKAN_OPENROUTER_API_KEY` resolves\n * the same as every other mikan-aliased credential, instead of the\n * package's default `process.env`-only context.\n */\nconst mikanAuthContext: AuthContext = {\n async env(name) {\n return readEnv(name);\n },\n async fileExists() {\n return false;\n },\n};\n\nlet cachedModels: ReturnType<typeof createBuiltinJevModels> | undefined;\n\nfunction models() {\n cachedModels ??= createBuiltinJevModels({ authContext: mikanAuthContext });\n return cachedModels;\n}\n\nfunction toGeminixiangQuestion(question: JevQuestion): GeminixiangQuestion {\n const instructions = question.instructions as GeminixiangEntry;\n if (question.type === \"boolean\") {\n // `@geminixiang/jev` leaves noul criteria optional; mikan has always sent\n // an explicit Yes/No default so the wire payload (and anything tuned\n // against it, e.g. the auto-reply gate) does not change under this swap.\n return {\n type: \"noul\",\n instructions,\n criteria: {\n true: (question.criteria?.true as GeminixiangEntry) ?? \"Yes\",\n false: (question.criteria?.false as GeminixiangEntry) ?? \"No\",\n },\n };\n }\n if (question.type === \"choice\") {\n return {\n type: \"choice\",\n instructions,\n criteria: question.criteria as Record<string, GeminixiangEntry>,\n };\n }\n const [first, second, ...rest] = question.criteria as GeminixiangEntry[];\n if (first === undefined || second === undefined) {\n throw new Error(\"score questions need at least two levels\");\n }\n return { type: \"score\", instructions, criteria: [first, second, ...rest] };\n}\n\nfunction fromGeminixiangAnswer(\n answer: GeminixiangAnswerFor<GeminixiangQuestion>,\n): JevAnswer<JevQuestion> {\n if (answer.type === \"noul\") {\n return { type: \"boolean\", probability: answer.noul };\n }\n if (answer.type === \"choice\") {\n return {\n type: \"choice\",\n choice: answer.choice,\n probabilities: answer.probabilities as Record<string, number>,\n confidence: answer.confidence,\n };\n }\n return {\n type: \"score\",\n score: answer.score,\n probabilities: answer.probabilities,\n legend: answer.legend as Record<string, string> | undefined,\n confidence: answer.confidence,\n };\n}\n\n/**\n * Evaluate one or more typed questions against a shared `state` using Jev,\n * reached through OpenRouter's decisions API by way of `@geminixiang/jev`.\n * Every question is scored independently against the same state in a\n * single request; batching questions here is cheap (they share the input)\n * and is preferred over separate calls per question.\n */\nexport async function evaluateWithJev<const QUESTIONS extends JevQuestions>(\n state: JevEntry,\n questions: QUESTIONS,\n options: EvaluateWithJevOptions = {},\n): Promise<JevResult<QUESTIONS>> {\n const catalogModel = models().getModel(\"openrouter\", \"jev-latest\");\n if (!catalogModel) throw new JevNotConfiguredError();\n // `options.model` is the wire model id callers already pass (e.g. from\n // JEV_MODEL_ID); override the catalog slug directly rather than adding a\n // second catalog entry per possible override.\n const model = options.model ? { ...catalogModel, slug: options.model } : catalogModel;\n\n const wireQuestions: Record<string, GeminixiangQuestion> = {};\n for (const [id, question] of Object.entries(questions)) {\n wireQuestions[id] = toGeminixiangQuestion(question);\n }\n\n let result;\n try {\n result = await models().evaluate(\n model,\n { state: state as GeminixiangEntry, questions: wireQuestions },\n {\n ...(options.headers ? { headers: options.headers } : {}),\n ...(options.abortSignal ? { signal: options.abortSignal } : {}),\n },\n );\n } catch (error) {\n if (error instanceof JevAuthError || error instanceof JevConfigError) {\n throw new JevNotConfiguredError();\n }\n if (error instanceof JevAPIError) {\n throw new JevRequestError(error.message, error.status);\n }\n if (\n error instanceof JevResponseError ||\n error instanceof JevConnectionError ||\n error instanceof JevTimeoutError\n ) {\n throw new JevRequestError(error.message, 502);\n }\n throw error;\n }\n\n const answers = {} as { [ID in keyof QUESTIONS]: JevAnswer<QUESTIONS[ID]> };\n for (const id of Object.keys(questions)) {\n const answer = result.answers[id];\n if (!answer) throw new JevRequestError(`Jev response missing answer for \"${id}\"`, 502);\n (answers as Record<string, JevAnswer<JevQuestion>>)[id] = fromGeminixiangAnswer(answer);\n }\n\n return {\n answers,\n usage: {\n inputTokens: result.usage.input,\n outputTokens: result.usage.output,\n cost: result.usage.cost.total,\n },\n model: result.model,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jev.js","sourceRoot":"","sources":["../../src/harness/jev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAIhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAkB,MAAM,2BAA2B,CAAC;AAE7E,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAqDnD,uFAAuF;AACvF,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C;QACE,KAAK,CACH,sHAAsH,CACvH,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YACE,OAAe,EACC,MAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC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QACD,IACE,KAAK,YAAY,gBAAgB;YACjC,KAAK,YAAY,kBAAkB;YACnC,KAAK,YAAY,eAAe,EAChC,CAAC;YACD,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IACD,gBAAgB,CAAC;QACf,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;QAC/B,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;QACjC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;QAChC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;KACnC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,EAA2D,CAAC;IAC5E,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,eAAe,CAAC,oCAAoC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACtF,OAAkD,CAAC,EAAE,CAAC,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO;QACL,OAAO;QACP,KAAK,EAAE;YACL,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;YAC/B,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;YACjC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;SAC9B;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Jev (typesafe/jev) client, backed by `@geminixiang/jev`.\n *\n * Jev is a \"System One\" evaluation model: it scores a shared `state`\n * against typed questions (a yes/no probability, a multiple choice, or a\n * position on an ordered scale) and returns calibrated probabilities. It\n * does not generate text or tool calls, so it cannot be driven through\n * pi-ai's `Provider`/`Model`/`stream()` contract the way every model\n * `models.ts` catalogs is — that contract is chat/completion shaped\n * (system prompt + messages in, streamed text/tool-call events out), and\n * Jev's typed-decision shape does not fit it. Jev is therefore not a\n * selectable chat provider: callers import `evaluateWithJev` directly at\n * whatever call site wants a fast, cheap, type-safe decision (e.g.\n * classification, routing, guardrails), and interpret the returned\n * probabilities themselves.\n *\n * `@geminixiang/jev` owns the wire protocol, provider catalog, and auth\n * resolution for four backends (TypeSafe, OpenRouter, Vercel AI Gateway,\n * Cloudflare Workers AI); this module picks OpenRouter (the same key\n * pi-ai's `openrouter` chat provider reads) and adapts its typed\n * request/answer shapes to the caller-facing contract mikan's call sites\n * already depend on, so this file is the only one that needs to know a\n * dependency swap happened.\n */\nimport {\n createBuiltinJevModels,\n JevAPIError,\n JevAuthError,\n JevConfigError,\n JevConnectionError,\n JevResponseError,\n JevTimeoutError,\n type AnswerFor as GeminixiangAnswerFor,\n type Entry as GeminixiangEntry,\n type Question as GeminixiangQuestion,\n} from \"@geminixiang/jev\";\nimport type { AuthContext } from \"@earendil-works/pi-ai\";\nimport { readEnv } from \"../env-manifest.js\";\nimport { recordJevOutcome, type JevCaller } from \"../observability/index.js\";\n\n/** The current public Jev model id on OpenRouter. */\nexport const JEV_MODEL_ID = \"~typesafe/jev-latest\";\n\n/**\n * Any value Jev accepts as text-bearing structure: a string, a JSON object,\n * an array, or `null`. State, instructions, and criteria descriptions all\n * take this shape; Jev is trained to read the structure, so objects with\n * labelled keys are preferred over string templates.\n */\nexport type JevEntry = string | number | boolean | null | JevEntry[] | { [key: string]: JevEntry };\n\n/** A shared caller-facing question shape; translated to `@geminixiang/jev`'s shape below. */\nexport type JevQuestion =\n | {\n type: \"boolean\";\n instructions: JevEntry;\n /** Optional descriptions of the yes / no outcomes. */\n criteria?: { true?: JevEntry; false?: JevEntry };\n }\n | { type: \"choice\"; instructions: JevEntry; criteria: Record<string, JevEntry> }\n | { type: \"score\"; instructions: JevEntry; criteria: readonly JevEntry[] };\n\nexport type JevQuestions = Record<string, JevQuestion>;\n\nexport type JevAnswer<QUESTION extends JevQuestion> = QUESTION extends { type: \"choice\" }\n ? {\n type: \"choice\";\n choice: string;\n probabilities?: Record<string, number>;\n /** 0-1 statistic over `probabilities`; low means no option clearly fits. */\n confidence?: number;\n }\n : QUESTION extends { type: \"score\" }\n ? {\n type: \"score\";\n /** Expected level index; fractional between levels. */\n score: number;\n probabilities?: Record<string, number>;\n /** Level index -> criterion text, as echoed by Jev. */\n legend?: Record<string, string>;\n confidence?: number;\n }\n : { type: \"boolean\"; probability: number };\n\nexport interface JevResult<QUESTIONS extends JevQuestions> {\n readonly answers: { [ID in keyof QUESTIONS]: JevAnswer<QUESTIONS[ID]> };\n readonly usage: {\n inputTokens: number | undefined;\n outputTokens: number | undefined;\n cost: number | undefined;\n };\n readonly model: string;\n}\n\n/** Thrown when no Jev backend has a usable credential. Callers fail closed on this. */\nexport class JevNotConfiguredError extends Error {\n constructor() {\n super(\n \"Jev requires OPENROUTER_API_KEY (an OpenRouter API key). Set it in the environment before calling evaluateWithJev().\",\n );\n this.name = \"JevNotConfiguredError\";\n }\n}\n\nexport class JevRequestError extends Error {\n constructor(\n message: string,\n public readonly status: number,\n ) {\n super(message);\n this.name = \"JevRequestError\";\n }\n}\n\nexport interface EvaluateWithJevOptions {\n /** Evaluation model id; defaults to the current public Jev model. */\n model?: string;\n abortSignal?: AbortSignal;\n headers?: Record<string, string>;\n /**\n * Which call site is asking, so Jev spend is attributable in Sentry/OTel\n * (`agent.jev.cost`, tagged `caller`) without any judged content leaving\n * this function. Required rather than defaulted so a new call site must\n * consciously pick an attribution instead of spend silently landing in a\n * generic bucket.\n */\n caller: JevCaller;\n}\n\n// ── @geminixiang/jev wiring ──────────────────────────────────────────────\n\n/**\n * Routes env reads through `readEnv` so `MIKAN_OPENROUTER_API_KEY` resolves\n * the same as every other mikan-aliased credential, instead of the\n * package's default `process.env`-only context.\n */\nconst mikanAuthContext: AuthContext = {\n async env(name) {\n return readEnv(name);\n },\n async fileExists() {\n return false;\n },\n};\n\nlet cachedModels: ReturnType<typeof createBuiltinJevModels> | undefined;\n\nfunction models() {\n cachedModels ??= createBuiltinJevModels({ authContext: mikanAuthContext });\n return cachedModels;\n}\n\nfunction toGeminixiangQuestion(question: JevQuestion): GeminixiangQuestion {\n const instructions = question.instructions as GeminixiangEntry;\n if (question.type === \"boolean\") {\n // `@geminixiang/jev` leaves noul criteria optional; mikan has always sent\n // an explicit Yes/No default so the wire payload (and anything tuned\n // against it, e.g. the auto-reply gate) does not change under this swap.\n return {\n type: \"noul\",\n instructions,\n criteria: {\n true: (question.criteria?.true as GeminixiangEntry) ?? \"Yes\",\n false: (question.criteria?.false as GeminixiangEntry) ?? \"No\",\n },\n };\n }\n if (question.type === \"choice\") {\n return {\n type: \"choice\",\n instructions,\n criteria: question.criteria as Record<string, GeminixiangEntry>,\n };\n }\n const [first, second, ...rest] = question.criteria as GeminixiangEntry[];\n if (first === undefined || second === undefined) {\n throw new Error(\"score questions need at least two levels\");\n }\n return { type: \"score\", instructions, criteria: [first, second, ...rest] };\n}\n\nfunction fromGeminixiangAnswer(\n answer: GeminixiangAnswerFor<GeminixiangQuestion>,\n): JevAnswer<JevQuestion> {\n if (answer.type === \"noul\") {\n return { type: \"boolean\", probability: answer.noul };\n }\n if (answer.type === \"choice\") {\n return {\n type: \"choice\",\n choice: answer.choice,\n probabilities: answer.probabilities as Record<string, number>,\n confidence: answer.confidence,\n };\n }\n return {\n type: \"score\",\n score: answer.score,\n probabilities: answer.probabilities,\n legend: answer.legend as Record<string, string> | undefined,\n confidence: answer.confidence,\n };\n}\n\n/**\n * Evaluate one or more typed questions against a shared `state` using Jev,\n * reached through OpenRouter's decisions API by way of `@geminixiang/jev`.\n * Every question is scored independently against the same state in a\n * single request; batching questions here is cheap (they share the input)\n * and is preferred over separate calls per question.\n */\nexport async function evaluateWithJev<const QUESTIONS extends JevQuestions>(\n state: JevEntry,\n questions: QUESTIONS,\n options: EvaluateWithJevOptions,\n): Promise<JevResult<QUESTIONS>> {\n const catalogModel = models().getModel(\"openrouter\", \"jev-latest\");\n if (!catalogModel) throw new JevNotConfiguredError();\n // `options.model` is the wire model id callers already pass (e.g. from\n // JEV_MODEL_ID); override the catalog slug directly rather than adding a\n // second catalog entry per possible override.\n const model = options.model ? { ...catalogModel, slug: options.model } : catalogModel;\n\n const wireQuestions: Record<string, GeminixiangQuestion> = {};\n for (const [id, question] of Object.entries(questions)) {\n wireQuestions[id] = toGeminixiangQuestion(question);\n }\n\n const startedAt = Date.now();\n let result;\n try {\n result = await models().evaluate(\n model,\n { state: state as GeminixiangEntry, questions: wireQuestions },\n {\n ...(options.headers ? { headers: options.headers } : {}),\n ...(options.abortSignal ? { signal: options.abortSignal } : {}),\n },\n );\n } catch (error) {\n recordJevOutcome({\n caller: options.caller,\n status: \"error\",\n errorType: error instanceof Error ? error.name : \"Error\",\n durationMs: Date.now() - startedAt,\n });\n if (error instanceof JevAuthError || error instanceof JevConfigError) {\n throw new JevNotConfiguredError();\n }\n if (error instanceof JevAPIError) {\n throw new JevRequestError(error.message, error.status);\n }\n if (\n error instanceof JevResponseError ||\n error instanceof JevConnectionError ||\n error instanceof JevTimeoutError\n ) {\n throw new JevRequestError(error.message, 502);\n }\n throw error;\n }\n recordJevOutcome({\n caller: options.caller,\n status: \"ok\",\n inputTokens: result.usage.input,\n outputTokens: result.usage.output,\n costUsd: result.usage.cost.total,\n durationMs: Date.now() - startedAt,\n });\n\n const answers = {} as { [ID in keyof QUESTIONS]: JevAnswer<QUESTIONS[ID]> };\n for (const id of Object.keys(questions)) {\n const answer = result.answers[id];\n if (!answer) throw new JevRequestError(`Jev response missing answer for \"${id}\"`, 502);\n (answers as Record<string, JevAnswer<JevQuestion>>)[id] = fromGeminixiangAnswer(answer);\n }\n\n return {\n answers,\n usage: {\n inputTokens: result.usage.input,\n outputTokens: result.usage.output,\n cost: result.usage.cost.total,\n },\n model: result.model,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenter.d.ts","sourceRoot":"","sources":["../../src/harness/presenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,GAAG,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAEV,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOtD,OAAO,KAAK,EAAE,qBAAqB,EAA4B,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AA+DxE,wBAAgB,cAAc,IAAI,kBAAkB,CAkCnD;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE;IACP,SAAS,EAAE,qBAAqB,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,GACA,eAAe,CAsEjB;AAOD,wBAAgB,yBAAyB,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEzF;
|
|
1
|
+
{"version":3,"file":"presenter.d.ts","sourceRoot":"","sources":["../../src/harness/presenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,GAAG,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAEV,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOtD,OAA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AE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;CAC7D,GAAG,IAAI,CAiBP"}
|
|
@@ -157,9 +157,14 @@ export function isEventTriggerAttribution(triggerAttribution) {
|
|
|
157
157
|
function extractToolLabel(toolName, args) {
|
|
158
158
|
const label = args?.label;
|
|
159
159
|
const text = typeof label === "string" ? label.trim() || toolName : toolName;
|
|
160
|
-
// Jev judgments are calibrated probabilities, not the model's own guess
|
|
161
|
-
//
|
|
162
|
-
|
|
160
|
+
// Jev judgments are calibrated probabilities, not the model's own guess,
|
|
161
|
+
// and jev_browser drives a real external browser; name the tool so the
|
|
162
|
+
// user can tell which steps came from either. Guard against doubling the
|
|
163
|
+
// name when no real label was supplied and text fell back to toolName.
|
|
164
|
+
if ((toolName === "jev" || toolName === "jev_browser") && text !== toolName) {
|
|
165
|
+
return `${toolName} · ${text}`;
|
|
166
|
+
}
|
|
167
|
+
return text;
|
|
163
168
|
}
|
|
164
169
|
/** Non-subagent tool activity lines; subagent calls render as the dashboard. */
|
|
165
170
|
function formatToolProgress(runState) {
|