@duratica/executor-omp 0.0.0-stage → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2026 ByteDance
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,64 @@
1
- # Temporary Holding Version
1
+ # Duratica OMP Executor
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@duratica/executor-omp` is the Oh-My-Pi RPC executor adapter for `@duratica/kernel`.
4
+
5
+ ```ts
6
+ import { createOmpExecutor } from '@duratica/executor-omp'
7
+
8
+ const executor = createOmpExecutor()
9
+ for await (const event of executor.execute({
10
+ title: 'Analyze request',
11
+ instructions: 'Inspect the workspace and return a structured result.',
12
+ model: 'provider/model',
13
+ workspace: '/workspace',
14
+ allowedOperations: ['read', 'grep'],
15
+ outputSchema: { type: 'object', properties: { result: { type: 'string' } } },
16
+ }, new AbortController().signal)) {
17
+ console.log(event)
18
+ }
19
+ ```
20
+
21
+ ## Responsibilities
22
+
23
+ - launch `omp --mode rpc`;
24
+ - negotiate JSONL RPC v2 when available;
25
+ - keep and restore sessions;
26
+ - drive OMP goal mode;
27
+ - convert OMP output and tool events into generic `ExecutorEvent` values;
28
+ - parse structured JSON output;
29
+ - enforce timeout and cancellation;
30
+ - reject overlapping executions that share one session key;
31
+ - stream operation and output events while the turn is active;
32
+ - return a resumable executor checkpoint and typed failure metadata (`code`, `retryable`, `sessionSafe`);
33
+ - terminate the OMP process tree.
34
+
35
+ The package contains no Precog, security, Nuxt, Candidate, Hunt or Disclosure dependency.
36
+
37
+ ## Environment
38
+
39
+ - `DAK_OMP_BIN`: OMP executable or wrapper path; default `omp`.
40
+ - `DAK_OMP_MODEL`: fallback model. Values beginning with `default/` defer selection to OMP.
41
+
42
+ Provider credentials remain owned by OMP and its configuration. They are not stored by `@duratica/kernel`.
43
+
44
+ ## Development
45
+
46
+ ```bash
47
+ pnpm install
48
+ pnpm typecheck
49
+ pnpm test
50
+ pnpm build
51
+ pnpm pack
52
+ ```
53
+
54
+ ## Publishing
55
+
56
+ Publish `@duratica/kernel` first, then verify its version is available on npm
57
+ before publishing this package:
58
+
59
+ ```bash
60
+ npm whoami --registry=https://registry.npmjs.org
61
+ npm view @duratica/kernel@0.1.0-alpha.1 version
62
+ pnpm typecheck && pnpm test && pnpm build
63
+ npm publish --tag alpha
64
+ ```
@@ -0,0 +1,13 @@
1
+ export interface AgentDeadline {
2
+ signal: AbortSignal;
3
+ timedOut(): boolean;
4
+ cancel(): void;
5
+ }
6
+ /**
7
+ * Combines the caller's cancellation with a per-run wall clock. The returned
8
+ * signal is the one every provider request and event consumer must observe so
9
+ * an aborted worker cannot leave a prompt running after the job is failed.
10
+ */
11
+ export declare function createAgentDeadline(parent: AbortSignal, timeoutMs: number): AgentDeadline;
12
+ export declare function abortMessage(signal: AbortSignal, fallback?: string): string;
13
+ //# sourceMappingURL=deadline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../src/deadline.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,IAAI,OAAO,CAAA;IACnB,MAAM,IAAI,IAAI,CAAA;CACf;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAsBzF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,SAAsB,GAAG,MAAM,CAKxF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Combines the caller's cancellation with a per-run wall clock. The returned
3
+ * signal is the one every provider request and event consumer must observe so
4
+ * an aborted worker cannot leave a prompt running after the job is failed.
5
+ */
6
+ export function createAgentDeadline(parent, timeoutMs) {
7
+ const controller = new AbortController();
8
+ let timeout;
9
+ let expired = false;
10
+ const forwardAbort = () => controller.abort(parent.reason);
11
+ if (parent.aborted)
12
+ controller.abort(parent.reason);
13
+ else
14
+ parent.addEventListener('abort', forwardAbort, { once: true });
15
+ if (timeoutMs > 0) {
16
+ timeout = setTimeout(() => {
17
+ expired = true;
18
+ controller.abort(new Error(`Agent run exceeded ${timeoutMs} ms`));
19
+ }, timeoutMs);
20
+ timeout.unref?.();
21
+ }
22
+ return {
23
+ signal: controller.signal,
24
+ timedOut: () => expired,
25
+ cancel: () => {
26
+ clearTimeout(timeout);
27
+ parent.removeEventListener('abort', forwardAbort);
28
+ },
29
+ };
30
+ }
31
+ export function abortMessage(signal, fallback = 'Agent run aborted') {
32
+ const reason = signal.reason;
33
+ if (reason instanceof Error)
34
+ return reason.message;
35
+ if (typeof reason === 'string' && reason.trim())
36
+ return reason;
37
+ return fallback;
38
+ }
39
+ //# sourceMappingURL=deadline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deadline.js","sourceRoot":"","sources":["../src/deadline.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAmB,EAAE,SAAiB;IACxE,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,IAAI,OAAmC,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC1D,IAAI,MAAM,CAAC,OAAO;QAAE,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;;QAC9C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACnE,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,OAAO,GAAG,IAAI,CAAA;YACd,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,SAAS,KAAK,CAAC,CAAC,CAAA;QACnE,CAAC,EAAE,SAAS,CAAC,CAAA;QACb,OAAO,CAAC,KAAK,EAAE,EAAE,CAAA;IACnB,CAAC;IACD,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO;QACvB,MAAM,EAAE,GAAG,EAAE;YACX,YAAY,CAAC,OAAO,CAAC,CAAA;YACrB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACnD,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAmB,EAAE,QAAQ,GAAG,mBAAmB;IAC9E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,IAAI,MAAM,YAAY,KAAK;QAAE,OAAO,MAAM,CAAC,OAAO,CAAA;IAClD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE;QAAE,OAAO,MAAM,CAAA;IAC9D,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { TaskExecutor } from '@duratica/kernel';
2
+ import { type JsonlRpcExit, type JsonlRpcLaunch } from './jsonl-rpc.js';
3
+ export { JsonlFrameDecoder, JSONL_PROVIDER_LINE_BYTES, ProviderStreamLimitError } from './jsonl-rpc.js';
4
+ export type { JsonlFrameProblem } from './jsonl-rpc.js';
5
+ export { parseStructuredOutput } from './structured-output.js';
6
+ export interface OmpTransport {
7
+ onMessage(callback: (message: Record<string, unknown>) => void): () => void;
8
+ onExit(callback: (exit: JsonlRpcExit) => void): () => void;
9
+ request(command: Record<string, unknown>, timeoutMs: number | null): Promise<unknown>;
10
+ startRequest?(command: Record<string, unknown>, timeoutMs?: number | null): {
11
+ id: string;
12
+ promise: Promise<unknown>;
13
+ };
14
+ requestStopWork?(command: Record<string, unknown>, timeoutMs?: number | null): Promise<void>;
15
+ send(message: Record<string, unknown>): void;
16
+ close(error?: Error): Promise<void>;
17
+ }
18
+ export type OmpTransportFactory = (launch: JsonlRpcLaunch) => OmpTransport;
19
+ export type OmpFailureCode = 'session_busy' | 'launch_failed' | 'protocol_failed' | 'request_timeout' | 'run_timeout' | 'cancelled' | 'invalid_output' | 'process_exited' | 'executor_failed';
20
+ export declare class OmpExecutorError extends Error {
21
+ readonly code: OmpFailureCode;
22
+ readonly retryable: boolean;
23
+ readonly sessionSafe: boolean;
24
+ constructor(code: OmpFailureCode, message: string, retryable: boolean, sessionSafe: boolean);
25
+ }
26
+ export declare function createOmpExecutor(createTransport?: OmpTransportFactory): TaskExecutor;
27
+ export declare const ompExecutor: TaskExecutor;
28
+ export default ompExecutor;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8C,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAGhG,OAAO,EAA+C,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpH,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AACvG,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAsC9D,MAAM,WAAW,YA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