oh-my-knowledge 0.52.3 → 0.54.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.
Files changed (106) hide show
  1. package/README.md +21 -1
  2. package/README.zh.md +21 -1
  3. package/dist/assets/agent-skills/omk/SKILL.md +6 -0
  4. package/dist/assets/agent-skills/omk/references/commands.md +1 -1
  5. package/dist/authoring/evolver.js +1 -1
  6. package/dist/authoring/generator.js +1 -1
  7. package/dist/cli/commands/eval/index.js +7 -6
  8. package/dist/cli/commands/install.js +5 -1
  9. package/dist/cli/lib/generation-failure-hint.js +6 -8
  10. package/dist/cli/lib/runtime-defaults.d.ts +2 -0
  11. package/dist/cli/lib/runtime-defaults.js +7 -4
  12. package/dist/dsh-plugin/cordis.patch.yml +3 -0
  13. package/dist/dsh-plugin/host-executor.d.ts +93 -0
  14. package/dist/dsh-plugin/host-executor.js +232 -0
  15. package/dist/dsh-plugin/index.d.ts +30 -0
  16. package/dist/dsh-plugin/index.js +275 -0
  17. package/dist/dsh-plugin/observe.d.ts +47 -0
  18. package/dist/dsh-plugin/observe.js +359 -0
  19. package/dist/dsh-plugin/protocol.d.ts +21 -0
  20. package/dist/dsh-plugin/protocol.js +229 -0
  21. package/dist/dsh-plugin/trace-adapter.d.ts +48 -0
  22. package/dist/dsh-plugin/trace-adapter.js +590 -0
  23. package/dist/eval-core/comparability.js +3 -0
  24. package/dist/eval-core/evaluation-execution.js +5 -13
  25. package/dist/eval-core/evaluation-reporting.d.ts +7 -4
  26. package/dist/eval-core/evaluation-reporting.js +39 -18
  27. package/dist/eval-core/judge-independence.d.ts +1 -1
  28. package/dist/eval-core/judge-independence.js +1 -1
  29. package/dist/eval-core/report-document.js +6 -0
  30. package/dist/eval-core/resume-compatibility.d.ts +1 -0
  31. package/dist/eval-core/resume-compatibility.js +5 -4
  32. package/dist/eval-workflows/batch-evaluation-workflow.js +1 -1
  33. package/dist/eval-workflows/evaluation-pipeline/preflight-warnings.js +4 -2
  34. package/dist/eval-workflows/evaluation-pipeline.d.ts +3 -1
  35. package/dist/eval-workflows/evaluation-pipeline.js +7 -3
  36. package/dist/eval-workflows/run-evaluation.d.ts +4 -2
  37. package/dist/eval-workflows/run-evaluation.js +7 -3
  38. package/dist/executors/{anthropic-api.d.ts → anthropic/api.d.ts} +1 -1
  39. package/dist/executors/{anthropic-api.js → anthropic/api.js} +4 -2
  40. package/dist/executors/{claude-cli.d.ts → anthropic/claude/cli.d.ts} +1 -1
  41. package/dist/executors/{claude-cli.js → anthropic/claude/cli.js} +5 -3
  42. package/dist/executors/anthropic/claude/protocol.d.ts +87 -0
  43. package/dist/executors/{claude-protocol.js → anthropic/claude/protocol.js} +6 -6
  44. package/dist/executors/{claude-sdk.d.ts → anthropic/claude/sdk.d.ts} +2 -2
  45. package/dist/executors/{claude-sdk.js → anthropic/claude/sdk.js} +8 -5
  46. package/dist/executors/anthropic/claude/trace.d.ts +9 -0
  47. package/dist/executors/{claude-sdk-trace.js → anthropic/claude/trace.js} +5 -5
  48. package/dist/executors/{capabilities.d.ts → core/capabilities.d.ts} +3 -5
  49. package/dist/executors/{capabilities.js → core/capabilities.js} +4 -11
  50. package/dist/executors/core/http.d.ts +6 -0
  51. package/dist/executors/core/http.js +19 -0
  52. package/dist/executors/core/limits.d.ts +2 -0
  53. package/dist/executors/core/limits.js +2 -0
  54. package/dist/executors/core/optional-dependencies.d.ts +7 -0
  55. package/dist/executors/core/optional-dependencies.js +35 -0
  56. package/dist/executors/core/registry.d.ts +145 -0
  57. package/dist/executors/core/registry.js +127 -0
  58. package/dist/executors/core/runtime-fingerprint.d.ts +13 -0
  59. package/dist/executors/{runtime-fingerprint.js → core/runtime-fingerprint.js} +119 -59
  60. package/dist/executors/core/runtime.d.ts +12 -0
  61. package/dist/executors/core/runtime.js +61 -0
  62. package/dist/executors/core/subprocess.d.ts +44 -0
  63. package/dist/executors/{shared.js → core/subprocess.js} +20 -156
  64. package/dist/executors/index.d.ts +4 -4
  65. package/dist/executors/index.js +26 -15
  66. package/dist/executors/{openai-api.d.ts → openai/api.d.ts} +1 -1
  67. package/dist/executors/{openai-api.js → openai/api.js} +4 -2
  68. package/dist/executors/{codex-cli.d.ts → openai/codex/cli.d.ts} +3 -3
  69. package/dist/executors/{codex-cli.js → openai/codex/cli.js} +5 -3
  70. package/dist/executors/openai/codex/protocol.d.ts +72 -0
  71. package/dist/executors/{codex-protocol.js → openai/codex/protocol.js} +33 -2
  72. package/dist/executors/{codex-sdk.d.ts → openai/codex/sdk.d.ts} +18 -4
  73. package/dist/executors/{codex-sdk.js → openai/codex/sdk.js} +7 -4
  74. package/dist/executors/{codex-cli-trace.d.ts → openai/codex/trace.d.ts} +2 -2
  75. package/dist/executors/{codex-cli-trace.js → openai/codex/trace.js} +4 -4
  76. package/dist/executors/{script.d.ts → script/index.d.ts} +1 -1
  77. package/dist/executors/{script.js → script/index.js} +6 -4
  78. package/dist/grading/judge.d.ts +1 -1
  79. package/dist/grading/judge.js +1 -1
  80. package/dist/observability/conversation-catalog.js +1 -1
  81. package/dist/observability/experience.js +4 -0
  82. package/dist/observability/inbox.d.ts +4 -1
  83. package/dist/observability/inbox.js +7 -2
  84. package/dist/observability/trace-ir.d.ts +6 -3
  85. package/dist/observability/turn-index.js +4 -0
  86. package/dist/renderer/conversation-renderer.js +20 -6
  87. package/dist/renderer/html-renderer.js +30 -11
  88. package/dist/renderer/knowledge-debugger-renderer.js +6 -1
  89. package/dist/renderer/observation-inbox-renderer.js +2 -2
  90. package/dist/renderer/trajectory-live.d.ts +1 -0
  91. package/dist/renderer/trajectory-live.js +5 -2
  92. package/dist/shared/trace-source-kind.js +1 -0
  93. package/dist/types/executor.d.ts +13 -2
  94. package/dist/types/judge.d.ts +2 -2
  95. package/dist/types/observability.d.ts +1 -1
  96. package/dist/types/trace.d.ts +1 -1
  97. package/package.json +25 -5
  98. package/dist/executors/claude-protocol.d.ts +0 -28
  99. package/dist/executors/claude-sdk-trace.d.ts +0 -9
  100. package/dist/executors/codex-protocol.d.ts +0 -24
  101. package/dist/executors/gemini.d.ts +0 -2
  102. package/dist/executors/gemini.js +0 -156
  103. package/dist/executors/runtime-fingerprint.d.ts +0 -6
  104. package/dist/executors/shared.d.ts +0 -226
  105. /package/dist/executors/{script-command.d.ts → script/command.d.ts} +0 -0
  106. /package/dist/executors/{script-command.js → script/command.js} +0 -0
@@ -0,0 +1,21 @@
1
+ import type { ExecResult } from '../types/index.js';
2
+ type UnknownRecord = Record<string, unknown>;
3
+ /** Host-owned DSH events consumed by OMK without importing DSH runtime types. */
4
+ export interface DshHostRunResult {
5
+ rootSessionId: string;
6
+ finalResponse: string;
7
+ /** Root and descendant events in host-observed receive order. */
8
+ events: Array<{
9
+ sessionId: string;
10
+ event: UnknownRecord;
11
+ traceRole: 'main' | 'subagent';
12
+ }>;
13
+ childSessionIds: string[];
14
+ }
15
+ /**
16
+ * Map DSH's append-only session log into OMK's source-neutral executor result.
17
+ * Root and descendant token/tool evidence are included; final output remains
18
+ * the root session's last assistant text.
19
+ */
20
+ export declare function buildDshHostResult(result: DshHostRunResult, wallClockDurationMs: number): ExecResult;
21
+ export {};
@@ -0,0 +1,229 @@
1
+ import { checkedSumTokenCounts, optionalTokenCount } from '../shared/token-usage.js';
2
+ import { normalizeToolIdentity } from '../shared/tool-identity.js';
3
+ import { safeSliceForJson } from '../util/safe-slice.js';
4
+ function isRecord(value) {
5
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
6
+ }
7
+ function nonEmptyString(value) {
8
+ return typeof value === 'string' && value.trim() ? value : undefined;
9
+ }
10
+ function finiteInteger(value) {
11
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0
12
+ ? value
13
+ : undefined;
14
+ }
15
+ function eventTimestamp(event) {
16
+ const time = finiteInteger(event.time);
17
+ if (time === undefined)
18
+ return undefined;
19
+ try {
20
+ return new Date(time).toISOString();
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ function contentBlocks(value) {
27
+ return Array.isArray(value) ? value.filter(isRecord) : [];
28
+ }
29
+ function textFromBlocks(value) {
30
+ if (typeof value === 'string')
31
+ return value;
32
+ return contentBlocks(value)
33
+ .flatMap((block) => block.type === 'text' && typeof block.text === 'string'
34
+ ? [block.text]
35
+ : [])
36
+ .join('');
37
+ }
38
+ function serializableToolInput(value) {
39
+ if (typeof value !== 'string')
40
+ return value ?? null;
41
+ try {
42
+ return JSON.parse(value);
43
+ }
44
+ catch {
45
+ return value;
46
+ }
47
+ }
48
+ function boundedToolOutput(value) {
49
+ if (typeof value === 'string')
50
+ return safeSliceForJson(value, 50_000);
51
+ return value ?? null;
52
+ }
53
+ function resultBlock(data) {
54
+ const message = isRecord(data.message) ? data.message : undefined;
55
+ return contentBlocks(message?.content).find((block) => block.type === 'tool-result');
56
+ }
57
+ function collectEvents(result) {
58
+ return result.events.map(({ sessionId, event, traceRole }) => ({
59
+ sessionId,
60
+ event,
61
+ traceRole,
62
+ }));
63
+ }
64
+ function terminalReason(events, rootSessionId) {
65
+ const terminal = [...events].reverse().find(({ sessionId, event }) => (sessionId === rootSessionId && event.type === 'turn/end'));
66
+ if (!terminal || !isRecord(terminal.event.data)) {
67
+ return { stopReason: 'unknown', error: 'dsh runtime reached idle without a root turn/end event' };
68
+ }
69
+ const reason = isRecord(terminal.event.data.reason) ? terminal.event.data.reason : undefined;
70
+ const stopReason = nonEmptyString(reason?.kind) ?? 'unknown';
71
+ if (stopReason === 'error') {
72
+ const failure = isRecord(reason?.error) ? reason.error : undefined;
73
+ return {
74
+ stopReason,
75
+ error: nonEmptyString(failure?.message) ?? 'dsh turn failed',
76
+ };
77
+ }
78
+ if (['aborted', 'blocked', 'interrupted'].includes(stopReason)) {
79
+ return { stopReason, error: `dsh turn ended with ${stopReason}` };
80
+ }
81
+ if (stopReason === 'max-tokens') {
82
+ return { stopReason, error: 'dsh turn ended after reaching the output-token limit' };
83
+ }
84
+ return { stopReason };
85
+ }
86
+ /**
87
+ * Map DSH's append-only session log into OMK's source-neutral executor result.
88
+ * Root and descendant token/tool evidence are included; final output remains
89
+ * the root session's last assistant text.
90
+ */
91
+ export function buildDshHostResult(result, wallClockDurationMs) {
92
+ const events = collectEvents(result);
93
+ const tools = new Map();
94
+ const orderedTools = [];
95
+ const turns = [];
96
+ let inputTokens = 0;
97
+ let outputTokens = 0;
98
+ let cacheReadTokens = 0;
99
+ let cacheCreationTokens = 0;
100
+ let usageReported = true;
101
+ let assistantMessages = 0;
102
+ let rootTurns = 0;
103
+ for (const record of events) {
104
+ const { event, sessionId, traceRole } = record;
105
+ const data = isRecord(event.data) ? event.data : {};
106
+ const eventType = nonEmptyString(event.type);
107
+ if (eventType === 'turn/end' && sessionId === result.rootSessionId)
108
+ rootTurns += 1;
109
+ if (eventType === 'assistant/message') {
110
+ assistantMessages += 1;
111
+ const message = isRecord(data.message) ? data.message : {};
112
+ const text = textFromBlocks(message.content);
113
+ const usage = isRecord(data.usage) ? data.usage : undefined;
114
+ const nextInput = optionalTokenCount(usage?.inputTokens);
115
+ const nextOutput = optionalTokenCount(usage?.outputTokens);
116
+ const nextCacheRead = usage?.cacheReadTokens === undefined
117
+ ? 0
118
+ : optionalTokenCount(usage.cacheReadTokens);
119
+ const nextCacheWrite = usage?.cacheWriteTokens === undefined
120
+ ? 0
121
+ : optionalTokenCount(usage.cacheWriteTokens);
122
+ const sums = usage && nextInput !== undefined && nextOutput !== undefined
123
+ && nextCacheRead !== undefined && nextCacheWrite !== undefined
124
+ ? {
125
+ input: checkedSumTokenCounts(inputTokens, nextInput),
126
+ output: checkedSumTokenCounts(outputTokens, nextOutput),
127
+ cacheRead: checkedSumTokenCounts(cacheReadTokens, nextCacheRead),
128
+ cacheWrite: checkedSumTokenCounts(cacheCreationTokens, nextCacheWrite),
129
+ }
130
+ : undefined;
131
+ if (!sums || Object.values(sums).some((value) => value === undefined)) {
132
+ usageReported = false;
133
+ }
134
+ else {
135
+ inputTokens = sums.input ?? inputTokens;
136
+ outputTokens = sums.output ?? outputTokens;
137
+ cacheReadTokens = sums.cacheRead ?? cacheReadTokens;
138
+ cacheCreationTokens = sums.cacheWrite ?? cacheCreationTokens;
139
+ }
140
+ turns.push({
141
+ role: 'assistant',
142
+ content: text,
143
+ });
144
+ continue;
145
+ }
146
+ if (eventType === 'user/message') {
147
+ const message = isRecord(data.message) ? data.message : data;
148
+ turns.push({ role: 'user', content: textFromBlocks(message.content) });
149
+ continue;
150
+ }
151
+ if (eventType === 'tool/call') {
152
+ const callId = nonEmptyString(data.callId);
153
+ const sourceName = nonEmptyString(data.name);
154
+ if (!callId || !sourceName)
155
+ continue;
156
+ const identity = normalizeToolIdentity({ sourceName });
157
+ const timestamp = eventTimestamp(event);
158
+ const info = {
159
+ tool: identity.name,
160
+ ...(identity.sourceName && { sourceTool: identity.sourceName }),
161
+ ...(identity.namespace && { toolNamespace: identity.namespace }),
162
+ ...(identity.provider && { toolProvider: identity.provider }),
163
+ input: serializableToolInput(data.arguments),
164
+ output: null,
165
+ status: 'unknown',
166
+ statusSource: 'unknown',
167
+ success: false,
168
+ callInstanceId: `${sessionId}:${callId}`,
169
+ toolUseId: callId,
170
+ ...(timestamp && { timestamp }),
171
+ sourceTrace: `dsh-host:${sessionId}`,
172
+ traceRole,
173
+ };
174
+ const turn = {
175
+ role: 'tool',
176
+ content: 'null',
177
+ toolCalls: [info],
178
+ };
179
+ const mutable = { info, turn };
180
+ tools.set(`${sessionId}\0${callId}`, mutable);
181
+ orderedTools.push(mutable);
182
+ turns.push(turn);
183
+ continue;
184
+ }
185
+ if (eventType === 'tool/result') {
186
+ const block = resultBlock(data);
187
+ const callId = nonEmptyString(block?.toolCallId);
188
+ if (!callId)
189
+ continue;
190
+ const tool = tools.get(`${sessionId}\0${callId}`);
191
+ if (!tool)
192
+ continue;
193
+ const failed = Boolean(data.error) || block?.isError === true;
194
+ const resultContent = contentBlocks(block?.content);
195
+ const textOutput = textFromBlocks(resultContent);
196
+ tool.info.output = boundedToolOutput(textOutput || resultContent);
197
+ tool.info.status = failed ? 'failure' : 'success';
198
+ tool.info.statusSource = 'runtime';
199
+ tool.info.success = !failed;
200
+ tool.turn.content = typeof tool.info.output === 'string'
201
+ ? tool.info.output
202
+ : JSON.stringify(tool.info.output);
203
+ }
204
+ }
205
+ const terminal = terminalReason(events, result.rootSessionId);
206
+ const output = result.finalResponse || null;
207
+ const successfulStop = terminal.stopReason === 'completed';
208
+ const error = terminal.error ?? (!output ? 'dsh runtime produced no root assistant output' : undefined);
209
+ return {
210
+ ok: successfulStop && Boolean(output) && !error,
211
+ output,
212
+ durationMs: wallClockDurationMs,
213
+ durationApiMs: wallClockDurationMs,
214
+ inputTokens,
215
+ outputTokens,
216
+ cacheReadTokens,
217
+ cacheCreationTokens,
218
+ tokenUsageReportedByExecutor: usageReported && assistantMessages > 0,
219
+ costUSD: 0,
220
+ costReportedByExecutor: false,
221
+ stopReason: terminal.stopReason,
222
+ numTurns: rootTurns,
223
+ fullNumTurns: assistantMessages,
224
+ numSubAgents: new Set(result.childSessionIds).size,
225
+ ...(error && { error }),
226
+ turns,
227
+ toolCalls: orderedTools.map(({ info }) => info),
228
+ };
229
+ }
@@ -0,0 +1,48 @@
1
+ import type { ExperienceTurnStatus } from '../types/index.js';
2
+ import { type TraceSession } from '../observability/trace-ir.js';
3
+ export interface DshSessionHeaderLike {
4
+ readonly version: number;
5
+ readonly id: string;
6
+ readonly createdAt: number;
7
+ readonly cwd?: string;
8
+ readonly parentSession?: string;
9
+ readonly seedLength?: number;
10
+ readonly origin?: string;
11
+ readonly delegationDepth?: number;
12
+ readonly agentPreset?: string;
13
+ }
14
+ export interface DshSessionEventLike {
15
+ readonly type: string;
16
+ readonly seq: number;
17
+ readonly time: number;
18
+ readonly data: unknown;
19
+ readonly ignorable?: true;
20
+ readonly sourceEventSeqs?: readonly number[];
21
+ readonly surfaceOp?: unknown;
22
+ }
23
+ export interface DshTraceIntegrity {
24
+ complete: boolean;
25
+ status: ExperienceTurnStatus;
26
+ unknownEventCount: number;
27
+ ignoredChunkCount: number;
28
+ unmatchedToolCallCount: number;
29
+ unmatchedToolResultCount: number;
30
+ openTurnCount: number;
31
+ openStepCount: number;
32
+ }
33
+ export interface DshTraceAdapterOptions {
34
+ rootRunId?: string;
35
+ role?: TraceSession['role'];
36
+ groupPath?: string;
37
+ }
38
+ export interface DshTraceAdapterResult {
39
+ session: TraceSession;
40
+ integrity: DshTraceIntegrity;
41
+ }
42
+ export declare class DshTraceUnsupportedEventError extends Error {
43
+ readonly eventType: string;
44
+ readonly seq: number;
45
+ constructor(eventType: string, seq: number);
46
+ }
47
+ /** Project one validated, backend-neutral DSH logical log into OMK Trace IR. */
48
+ export declare function adaptDshSession(header: DshSessionHeaderLike, inputEvents: readonly DshSessionEventLike[], options?: DshTraceAdapterOptions): DshTraceAdapterResult;