@osovv/vv-opencode 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +88 -87
- package/dist/commands/completion.js +0 -1
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/doctor.js +6 -9
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +7 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts +4 -0
- package/dist/commands/install.js +40 -37
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/launch.d.ts +2 -1
- package/dist/commands/launch.js +18 -14
- package/dist/commands/launch.js.map +1 -1
- package/dist/commands/patch-provider.d.ts +225 -307
- package/dist/commands/patch-provider.js +92 -296
- package/dist/commands/patch-provider.js.map +1 -1
- package/dist/commands/status.js +7 -10
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +4 -0
- package/dist/commands/sync.js +38 -35
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.d.ts +25 -5
- package/dist/index.js +73 -34
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-tool-catalog.d.ts +1 -1
- package/dist/lib/agent-tool-catalog.js +3 -6
- package/dist/lib/agent-tool-catalog.js.map +1 -1
- package/dist/lib/agent-tool-contract.d.ts +22 -13
- package/dist/lib/agent-tool-contract.js +20 -20
- package/dist/lib/agent-tool-contract.js.map +1 -1
- package/dist/lib/analytics/types.d.ts +7 -1
- package/dist/lib/analytics/types.js +2 -2
- package/dist/lib/analytics/types.js.map +1 -1
- package/dist/lib/config-layers.d.ts +28 -6
- package/dist/lib/config-layers.js +268 -73
- package/dist/lib/config-layers.js.map +1 -1
- package/dist/lib/managed-agents.d.ts +24 -2
- package/dist/lib/managed-agents.js +45 -15
- package/dist/lib/managed-agents.js.map +1 -1
- package/dist/lib/model-roles.d.ts +5 -0
- package/dist/lib/model-roles.js +22 -1
- package/dist/lib/model-roles.js.map +1 -1
- package/dist/lib/opencode/agent-registrations.d.ts +4 -4
- package/dist/lib/opencode/agent-registrations.js +386 -197
- package/dist/lib/opencode/agent-registrations.js.map +1 -1
- package/dist/lib/opencode/inspection.d.ts +13 -13
- package/dist/lib/opencode/inspection.js +69 -106
- package/dist/lib/opencode/inspection.js.map +1 -1
- package/dist/lib/opencode/model-overrides.d.ts +2 -2
- package/dist/lib/opencode/model-overrides.js +192 -47
- package/dist/lib/opencode/model-overrides.js.map +1 -1
- package/dist/lib/opencode/paths.d.ts +6 -2
- package/dist/lib/opencode/paths.js +12 -11
- package/dist/lib/opencode/paths.js.map +1 -1
- package/dist/lib/opencode/plugin-registration.d.ts +10 -11
- package/dist/lib/opencode/plugin-registration.js +76 -138
- package/dist/lib/opencode/plugin-registration.js.map +1 -1
- package/dist/lib/opencode/shared-utils.d.ts +47 -3
- package/dist/lib/opencode/shared-utils.js +346 -15
- package/dist/lib/opencode/shared-utils.js.map +1 -1
- package/dist/lib/opencode.d.ts +5 -6
- package/dist/lib/opencode.js +10 -10
- package/dist/lib/opencode.js.map +1 -1
- package/dist/lib/vvoc-config.js +4 -4
- package/dist/lib/vvoc-config.js.map +1 -1
- package/dist/lib/vvoc-paths.d.ts +7 -0
- package/dist/lib/vvoc-paths.js +15 -1
- package/dist/lib/vvoc-paths.js.map +1 -1
- package/dist/lib/vvoc-preset-registry.d.ts +38 -50
- package/dist/lib/vvoc-preset-registry.js +38 -48
- package/dist/lib/vvoc-preset-registry.js.map +1 -1
- package/dist/plugins/analytics/index.d.ts +20 -14
- package/dist/plugins/analytics/index.js +281 -133
- package/dist/plugins/analytics/index.js.map +1 -1
- package/dist/plugins/guardian/index.d.ts +63 -42
- package/dist/plugins/guardian/index.js +217 -759
- package/dist/plugins/guardian/index.js.map +1 -1
- package/dist/plugins/hashline-edit/index.d.ts +145 -31
- package/dist/plugins/hashline-edit/index.js +679 -244
- package/dist/plugins/hashline-edit/index.js.map +1 -1
- package/dist/plugins/hashline-edit/schemas.d.ts +1 -1
- package/dist/plugins/hashline-edit/schemas.js +3 -3
- package/dist/plugins/hashline-edit/schemas.js.map +1 -1
- package/dist/plugins/model-roles/index.d.ts +18 -4
- package/dist/plugins/model-roles/index.js +44 -181
- package/dist/plugins/model-roles/index.js.map +1 -1
- package/dist/plugins/peak-hours/index.d.ts +23 -23
- package/dist/plugins/peak-hours/index.js +211 -180
- package/dist/plugins/peak-hours/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/deep.js +35 -51
- package/dist/plugins/secrets-redaction/deep.js.map +1 -1
- package/dist/plugins/secrets-redaction/index.d.ts +96 -8
- package/dist/plugins/secrets-redaction/index.js +290 -102
- package/dist/plugins/secrets-redaction/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/session.d.ts +9 -0
- package/dist/plugins/secrets-redaction/session.js +21 -4
- package/dist/plugins/secrets-redaction/session.js.map +1 -1
- package/dist/plugins/secrets-redaction/stream.d.ts +92 -0
- package/dist/plugins/secrets-redaction/stream.js +772 -0
- package/dist/plugins/secrets-redaction/stream.js.map +1 -0
- package/dist/plugins/spec-guard/index.d.ts +49 -18
- package/dist/plugins/spec-guard/index.js +231 -129
- package/dist/plugins/spec-guard/index.js.map +1 -1
- package/dist/plugins/system-context-injection/index.d.ts +10 -4
- package/dist/plugins/system-context-injection/index.js +271 -78
- package/dist/plugins/system-context-injection/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/index.d.ts +26 -4
- package/dist/plugins/tool-history-compaction/index.js +170 -32
- package/dist/plugins/tool-history-compaction/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/transform.d.ts +47 -16
- package/dist/plugins/tool-history-compaction/transform.js +173 -55
- package/dist/plugins/tool-history-compaction/transform.js.map +1 -1
- package/dist/plugins/web-tools/fetch-service.d.ts +51 -13
- package/dist/plugins/web-tools/fetch-service.js +106 -75
- package/dist/plugins/web-tools/fetch-service.js.map +1 -1
- package/dist/plugins/web-tools/index.d.ts +58 -16
- package/dist/plugins/web-tools/index.js +202 -91
- package/dist/plugins/web-tools/index.js.map +1 -1
- package/dist/plugins/web-tools/media-loader.d.ts +3 -3
- package/dist/plugins/web-tools/media-loader.js +3 -3
- package/dist/plugins/web-tools/media-loader.js.map +1 -1
- package/dist/plugins/web-tools/providers/native-fetch.d.ts +2 -2
- package/dist/plugins/web-tools/providers/native-fetch.js +1 -1
- package/dist/plugins/web-tools/providers/native-fetch.js.map +1 -1
- package/dist/plugins/web-tools/providers/spider.d.ts +2 -2
- package/dist/plugins/web-tools/providers/spider.js +1 -1
- package/dist/plugins/web-tools/providers/spider.js.map +1 -1
- package/dist/plugins/web-tools/providers/zai.d.ts +2 -2
- package/dist/plugins/web-tools/providers/zai.js +1 -1
- package/dist/plugins/web-tools/providers/zai.js.map +1 -1
- package/dist/plugins/web-tools/schemas.d.ts +1 -1
- package/dist/plugins/web-tools/schemas.js +3 -3
- package/dist/plugins/web-tools/schemas.js.map +1 -1
- package/dist/plugins/web-tools/search-service.d.ts +81 -12
- package/dist/plugins/web-tools/search-service.js +104 -57
- package/dist/plugins/web-tools/search-service.js.map +1 -1
- package/dist/plugins/workflow/authorization.d.ts +44 -10
- package/dist/plugins/workflow/authorization.js +113 -73
- package/dist/plugins/workflow/authorization.js.map +1 -1
- package/dist/plugins/workflow/cancellation.d.ts +86 -0
- package/dist/plugins/workflow/cancellation.js +202 -0
- package/dist/plugins/workflow/cancellation.js.map +1 -0
- package/dist/plugins/workflow/checkpoints.d.ts +7 -1
- package/dist/plugins/workflow/checkpoints.js +141 -21
- package/dist/plugins/workflow/checkpoints.js.map +1 -1
- package/dist/plugins/workflow/delegated.d.ts +14 -0
- package/dist/plugins/workflow/delegated.js +6 -5
- package/dist/plugins/workflow/delegated.js.map +1 -1
- package/dist/plugins/workflow/host.d.ts +81 -0
- package/dist/plugins/workflow/host.js +189 -0
- package/dist/plugins/workflow/host.js.map +1 -0
- package/dist/plugins/workflow/index.d.ts +69 -4
- package/dist/plugins/workflow/index.js +1391 -1026
- package/dist/plugins/workflow/index.js.map +1 -1
- package/dist/plugins/workflow/recovery.d.ts +3 -5
- package/dist/plugins/workflow/recovery.js +18 -33
- package/dist/plugins/workflow/recovery.js.map +1 -1
- package/dist/plugins/workflow/repair.d.ts +31 -5
- package/dist/plugins/workflow/repair.js +116 -48
- package/dist/plugins/workflow/repair.js.map +1 -1
- package/dist/plugins/workflow/results.d.ts +31 -31
- package/dist/plugins/workflow/results.js +4 -4
- package/dist/plugins/workflow/results.js.map +1 -1
- package/dist/plugins/workflow/schemas.d.ts +3 -3
- package/dist/plugins/workflow/schemas.js +5 -5
- package/dist/plugins/workflow/schemas.js.map +1 -1
- package/dist/plugins/workflow/system-instruction.md +4 -0
- package/dist/plugins/workflow/tooling.d.ts +6 -0
- package/dist/plugins/workflow/tooling.js +3 -1
- package/dist/plugins/workflow/tooling.js.map +1 -1
- package/dist/runtime/auxiliary.d.ts +13 -0
- package/dist/runtime/auxiliary.js +108 -0
- package/dist/runtime/auxiliary.js.map +1 -0
- package/dist/runtime/client.d.ts +88 -0
- package/dist/runtime/client.js +174 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/context-inspection-contract.d.ts +397 -0
- package/dist/runtime/context-inspection-contract.js +622 -0
- package/dist/runtime/context-inspection-contract.js.map +1 -0
- package/dist/runtime/context-inspection.d.ts +52 -0
- package/dist/runtime/context-inspection.js +324 -0
- package/dist/runtime/context-inspection.js.map +1 -0
- package/dist/runtime/context.d.ts +192 -0
- package/dist/runtime/context.js +1246 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/coordination.d.ts +40 -0
- package/dist/runtime/coordination.js +87 -0
- package/dist/runtime/coordination.js.map +1 -0
- package/dist/runtime/model-registry.d.ts +34 -0
- package/dist/runtime/model-registry.js +227 -0
- package/dist/runtime/model-registry.js.map +1 -0
- package/dist/runtime/permissions.d.ts +20 -0
- package/dist/runtime/permissions.js +250 -0
- package/dist/runtime/permissions.js.map +1 -0
- package/dist/runtime/snapshot-config.d.ts +80 -0
- package/dist/runtime/snapshot-config.js +268 -0
- package/dist/runtime/snapshot-config.js.map +1 -0
- package/dist/runtime/snapshot-store.d.ts +25 -0
- package/dist/runtime/snapshot-store.js +519 -0
- package/dist/runtime/snapshot-store.js.map +1 -0
- package/dist/runtime/snapshots.d.ts +59 -0
- package/dist/runtime/snapshots.js +721 -0
- package/dist/runtime/snapshots.js.map +1 -0
- package/dist/runtime/types.d.ts +713 -0
- package/dist/runtime/types.js +190 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/tui/analytics/indicator.d.ts +25 -26
- package/dist/tui/analytics/indicator.js +66 -74
- package/dist/tui/analytics/indicator.js.map +1 -1
- package/dist/tui/branding/footer.d.ts +7 -12
- package/dist/tui/branding/footer.js +16 -24
- package/dist/tui/branding/footer.js.map +1 -1
- package/dist/tui/context/analyze.d.ts +20 -9
- package/dist/tui/context/analyze.js +295 -257
- package/dist/tui/context/analyze.js.map +1 -1
- package/dist/tui/context/collect.d.ts +29 -3
- package/dist/tui/context/collect.js +450 -66
- package/dist/tui/context/collect.js.map +1 -1
- package/dist/tui/context/plugin.d.ts +21 -7
- package/dist/tui/context/plugin.js +65 -70
- package/dist/tui/context/plugin.js.map +1 -1
- package/dist/tui/context/types.d.ts +174 -43
- package/dist/tui/context/types.js +25 -19
- package/dist/tui/context/types.js.map +1 -1
- package/dist/tui/context/view.d.ts +33 -7
- package/dist/tui/context/view.js +136 -81
- package/dist/tui/context/view.js.map +1 -1
- package/dist/tui/peak-hours/banner.d.ts +13 -11
- package/dist/tui/peak-hours/banner.js +48 -80
- package/dist/tui/peak-hours/banner.js.map +1 -1
- package/dist/tui/policy.d.ts +69 -0
- package/dist/tui/policy.js +169 -0
- package/dist/tui/policy.js.map +1 -0
- package/dist/tui.d.ts +3 -8
- package/dist/tui.js +72 -68
- package/dist/tui.js.map +1 -1
- package/package.json +18 -14
- package/schemas/vvoc/v3.json +1 -1
- package/server.js +3 -5
- package/templates/agents/enhancer.md +10 -5
- package/templates/agents/guardian.md +10 -4
- package/templates/agents/investigator.md +4 -2
- package/templates/agents/vv-code-reviewer.md +4 -2
- package/templates/agents/vv-spec-reviewer.md +4 -2
- package/templates/skills/vv-execute/references/tool-contracts.md +1 -1
- package/tui.js +3 -5
- package/dist/plugins/analytics/v2.d.ts +0 -21
- package/dist/plugins/analytics/v2.js +0 -133
- package/dist/plugins/analytics/v2.js.map +0 -1
- package/dist/plugins/guardian/v2.d.ts +0 -13
- package/dist/plugins/guardian/v2.js +0 -204
- package/dist/plugins/guardian/v2.js.map +0 -1
- package/dist/plugins/hashline-edit/v2.d.ts +0 -12
- package/dist/plugins/hashline-edit/v2.js +0 -145
- package/dist/plugins/hashline-edit/v2.js.map +0 -1
- package/dist/plugins/model-roles/v2.d.ts +0 -24
- package/dist/plugins/model-roles/v2.js +0 -274
- package/dist/plugins/model-roles/v2.js.map +0 -1
- package/dist/plugins/peak-hours/v2.d.ts +0 -12
- package/dist/plugins/peak-hours/v2.js +0 -99
- package/dist/plugins/peak-hours/v2.js.map +0 -1
- package/dist/plugins/secrets-redaction/v2.d.ts +0 -19
- package/dist/plugins/secrets-redaction/v2.js +0 -138
- package/dist/plugins/secrets-redaction/v2.js.map +0 -1
- package/dist/plugins/spec-guard/v2.d.ts +0 -12
- package/dist/plugins/spec-guard/v2.js +0 -139
- package/dist/plugins/spec-guard/v2.js.map +0 -1
- package/dist/plugins/system-context-injection/agent-contexts.d.ts +0 -5
- package/dist/plugins/system-context-injection/agent-contexts.js +0 -164
- package/dist/plugins/system-context-injection/agent-contexts.js.map +0 -1
- package/dist/plugins/system-context-injection/v2.d.ts +0 -13
- package/dist/plugins/system-context-injection/v2.js +0 -60
- package/dist/plugins/system-context-injection/v2.js.map +0 -1
- package/dist/plugins/tool-history-compaction/v2.d.ts +0 -11
- package/dist/plugins/tool-history-compaction/v2.js +0 -56
- package/dist/plugins/tool-history-compaction/v2.js.map +0 -1
- package/dist/plugins/v2-runtime/config-watcher.d.ts +0 -26
- package/dist/plugins/v2-runtime/config-watcher.js +0 -111
- package/dist/plugins/v2-runtime/config-watcher.js.map +0 -1
- package/dist/plugins/v2-runtime/index.d.ts +0 -50
- package/dist/plugins/v2-runtime/index.js +0 -114
- package/dist/plugins/v2-runtime/index.js.map +0 -1
- package/dist/plugins/v2-runtime/location-config.d.ts +0 -51
- package/dist/plugins/v2-runtime/location-config.js +0 -91
- package/dist/plugins/v2-runtime/location-config.js.map +0 -1
- package/dist/plugins/v2-runtime/setup.d.ts +0 -48
- package/dist/plugins/v2-runtime/setup.js +0 -174
- package/dist/plugins/v2-runtime/setup.js.map +0 -1
- package/dist/plugins/web-tools/v2.d.ts +0 -11
- package/dist/plugins/web-tools/v2.js +0 -99
- package/dist/plugins/web-tools/v2.js.map +0 -1
- package/dist/plugins/workflow/v2.d.ts +0 -76
- package/dist/plugins/workflow/v2.js +0 -283
- package/dist/plugins/workflow/v2.js.map +0 -1
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
import type { OpenCodeClient, PermissionEffect, PermissionGetInput, PermissionGetOutput, PermissionReplyInput } from "@opencode/client";
|
|
2
|
+
import type { Rpc } from "@opencode/schema/rpc";
|
|
3
|
+
import type { RpcHandlers } from "@opencode/plugin/promise/rpc";
|
|
4
|
+
import type { DeepMutable } from "@opencode/plugin/promise/types";
|
|
5
|
+
import type { RawOpenCodeModelIntent } from "../lib/config-layers.js";
|
|
6
|
+
import type { VvocConfig } from "../lib/vvoc-config.js";
|
|
7
|
+
import type { Agent } from "@opencode/schema/agent";
|
|
8
|
+
import type { Model } from "@opencode/schema/model";
|
|
9
|
+
import type { Permission } from "@opencode/schema/permission";
|
|
10
|
+
import type { Session } from "@opencode/schema/session";
|
|
11
|
+
/** Exact native host version this runtime authenticates against; the pinned host is 2.0.18. */
|
|
12
|
+
export declare const SUPPORTED_SERVICE_VERSION = "2.0.18";
|
|
13
|
+
/** Native event type carrying a terminal permission reply. */
|
|
14
|
+
export declare const PERMISSION_REPLIED_EVENT = "permission.replied";
|
|
15
|
+
/** Native event proving the live event transport finished its handshake. */
|
|
16
|
+
export declare const SERVER_CONNECTED_EVENT = "server.connected";
|
|
17
|
+
/**
|
|
18
|
+
* Structural subset of `Location.Info` the runtime needs. The native
|
|
19
|
+
* `Location.Info` class satisfies it, and tests can build plain objects.
|
|
20
|
+
*/
|
|
21
|
+
export interface RuntimeLocation {
|
|
22
|
+
readonly directory: string;
|
|
23
|
+
readonly workspaceID?: string | undefined;
|
|
24
|
+
readonly project: {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly directory: string;
|
|
27
|
+
readonly canonical: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Stable per-location identity used to share one runtime inside a host. */
|
|
31
|
+
export interface RuntimeIdentity {
|
|
32
|
+
readonly directory: string;
|
|
33
|
+
readonly workspaceID?: string | undefined;
|
|
34
|
+
readonly projectID: string;
|
|
35
|
+
readonly canonical: string;
|
|
36
|
+
}
|
|
37
|
+
/** Releasable native RPC registration handle. Disposing it never stops the host. */
|
|
38
|
+
export interface RuntimeRpcRegistration {
|
|
39
|
+
dispose(): Promise<void> | void;
|
|
40
|
+
}
|
|
41
|
+
/** Narrow structural view of the native plugin context RPC registrar. */
|
|
42
|
+
export interface RuntimeRpcRegistrar {
|
|
43
|
+
register<const D extends Rpc.PortableDefinition>(definition: D, handlers: RpcHandlers<NoInfer<D>>): Promise<RuntimeRpcRegistration>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Narrow structural view of a native `Plugin.Context` used to acquire a
|
|
47
|
+
* runtime. A real `Plugin.Context` satisfies it; the full context stays with
|
|
48
|
+
* the owning plugin.
|
|
49
|
+
*/
|
|
50
|
+
export interface RuntimeContext {
|
|
51
|
+
readonly location: RuntimeLocation;
|
|
52
|
+
readonly rpc: RuntimeRpcRegistrar;
|
|
53
|
+
/**
|
|
54
|
+
* Native app object copied from the host instance, used only as a cross-context
|
|
55
|
+
* coordination identity. Optional so a context without it still acquires a
|
|
56
|
+
* runtime; distinct contexts copied from one host share the same app reference.
|
|
57
|
+
*/
|
|
58
|
+
readonly app?: object | undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Location and cancellation options for an authenticated client RPC call. */
|
|
61
|
+
export interface RuntimeRpcCallOptions {
|
|
62
|
+
readonly location?: {
|
|
63
|
+
readonly directory?: string | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
readonly signal?: AbortSignal | undefined;
|
|
66
|
+
}
|
|
67
|
+
/** Method map projected from a portable RPC definition. */
|
|
68
|
+
export type RuntimeRpcMethods<D extends Rpc.PortableDefinition> = {
|
|
69
|
+
readonly [Name in keyof D["methods"]]: (input: Rpc.Input<D["methods"][Name]["input"]>, options?: RuntimeRpcCallOptions) => Promise<Rpc.Output<D["methods"][Name]["output"]>>;
|
|
70
|
+
};
|
|
71
|
+
/** Callable projection of an authenticated native client RPC. */
|
|
72
|
+
export interface RuntimeRpcClient {
|
|
73
|
+
<D extends Rpc.PortableDefinition>(definition: D): RuntimeRpcMethods<D>;
|
|
74
|
+
}
|
|
75
|
+
/** Structural native event envelope. */
|
|
76
|
+
export interface RuntimeEvent {
|
|
77
|
+
readonly type: string;
|
|
78
|
+
readonly data?: unknown;
|
|
79
|
+
/** Native event creation time in epoch milliseconds, when supplied. */
|
|
80
|
+
readonly created?: unknown;
|
|
81
|
+
/** Native durable envelope carrying the per-aggregate sequence. */
|
|
82
|
+
readonly durable?: {
|
|
83
|
+
readonly aggregateID?: unknown;
|
|
84
|
+
readonly seq?: unknown;
|
|
85
|
+
} | undefined;
|
|
86
|
+
}
|
|
87
|
+
/** Structural native live-event subscription API. */
|
|
88
|
+
export interface RuntimeEventApi {
|
|
89
|
+
subscribe(options?: {
|
|
90
|
+
readonly signal?: AbortSignal | undefined;
|
|
91
|
+
}): AsyncIterable<RuntimeEvent>;
|
|
92
|
+
}
|
|
93
|
+
/** Structural native session permission create/get/reply API. */
|
|
94
|
+
export interface RuntimePermissionApi {
|
|
95
|
+
create(input: PermissionCreateInput, options?: {
|
|
96
|
+
readonly signal?: AbortSignal | undefined;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly effect: PermissionEffect;
|
|
100
|
+
}>;
|
|
101
|
+
get(input: PermissionGetInput, options?: {
|
|
102
|
+
readonly signal?: AbortSignal | undefined;
|
|
103
|
+
}): Promise<PermissionGetOutput>;
|
|
104
|
+
reply(input: PermissionReplyInput, options?: {
|
|
105
|
+
readonly signal?: AbortSignal | undefined;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
/** Minimal input accepted by `permission.create`, kept in sync with the native contract. */
|
|
109
|
+
export interface PermissionCreateInput {
|
|
110
|
+
readonly sessionID: string;
|
|
111
|
+
readonly id?: string | null | undefined;
|
|
112
|
+
readonly action: string;
|
|
113
|
+
readonly resources: ReadonlyArray<string>;
|
|
114
|
+
readonly save?: ReadonlyArray<string> | undefined;
|
|
115
|
+
readonly metadata?: Record<string, unknown> | undefined;
|
|
116
|
+
readonly source?: Permission.Source | undefined;
|
|
117
|
+
readonly agent?: string | null | undefined;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Structural subset of the native client used by the runtime foundation. The
|
|
121
|
+
* full `OpenCodeClient` satisfies it, and later plugins receive the full client
|
|
122
|
+
* from the default runtime.
|
|
123
|
+
*/
|
|
124
|
+
export interface RuntimeClient {
|
|
125
|
+
readonly rpc: RuntimeRpcClient;
|
|
126
|
+
readonly permission: RuntimePermissionApi;
|
|
127
|
+
readonly event: RuntimeEventApi;
|
|
128
|
+
}
|
|
129
|
+
/** Native local-service endpoint handed to a full client. Never log its credentials. */
|
|
130
|
+
export interface RuntimeEndpoint {
|
|
131
|
+
readonly url: string;
|
|
132
|
+
readonly auth?: {
|
|
133
|
+
readonly type: "basic";
|
|
134
|
+
readonly username: string;
|
|
135
|
+
readonly password: string;
|
|
136
|
+
} | undefined;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Injectable native boundary. The default implementation uses
|
|
140
|
+
* `Service.discover`/`Service.headers`/`OpenCode.make`; tests provide faithful
|
|
141
|
+
* in-memory implementations.
|
|
142
|
+
*/
|
|
143
|
+
export interface RuntimeDeps<Client extends RuntimeClient = OpenCodeClient> {
|
|
144
|
+
/** Exact version required from the already-running service. */
|
|
145
|
+
readonly serviceVersion: string;
|
|
146
|
+
/** Discover a healthy, compatible already-running service; never starts one. */
|
|
147
|
+
discoverService(options: {
|
|
148
|
+
readonly version: string;
|
|
149
|
+
}): Promise<RuntimeEndpoint | undefined>;
|
|
150
|
+
/** Create native basic-auth headers from the service registration. */
|
|
151
|
+
serviceHeaders(endpoint: RuntimeEndpoint): Record<string, string> | undefined;
|
|
152
|
+
/** Build the full native client for the discovered endpoint. */
|
|
153
|
+
makeClient(options: {
|
|
154
|
+
readonly baseUrl: string;
|
|
155
|
+
readonly headers?: Record<string, string> | undefined;
|
|
156
|
+
}): Client;
|
|
157
|
+
}
|
|
158
|
+
/** Resource-specific permission request passed to the native host. */
|
|
159
|
+
export interface ResourcePermissionRequest {
|
|
160
|
+
readonly sessionID: Session.ID;
|
|
161
|
+
readonly action: string;
|
|
162
|
+
readonly resources: ReadonlyArray<string>;
|
|
163
|
+
readonly save?: ReadonlyArray<string> | undefined;
|
|
164
|
+
readonly metadata?: Record<string, unknown> | undefined;
|
|
165
|
+
readonly source?: Permission.Source | undefined;
|
|
166
|
+
readonly agent?: Agent.ID | undefined;
|
|
167
|
+
}
|
|
168
|
+
/** Terminal permission decision: allow or deny. */
|
|
169
|
+
export type PermissionDecision = "allow" | "deny";
|
|
170
|
+
/** Cancellation and bounded-readiness options for an awaited permission decision. */
|
|
171
|
+
export interface PermissionRequestOptions {
|
|
172
|
+
readonly signal?: AbortSignal | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* Bounds how long to wait for the native event transport handshake before the
|
|
175
|
+
* request is created. Defaults to `DEFAULT_PERMISSION_READINESS_TIMEOUT_MS`.
|
|
176
|
+
*/
|
|
177
|
+
readonly readinessTimeoutMs?: number | undefined;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Awaited resource permission service. `request` creates the native request and
|
|
181
|
+
* waits for its terminal state; `guard` runs a side effect only after a
|
|
182
|
+
* terminal allow.
|
|
183
|
+
*/
|
|
184
|
+
export interface PermissionService {
|
|
185
|
+
request(input: ResourcePermissionRequest, options?: PermissionRequestOptions): Promise<PermissionDecision>;
|
|
186
|
+
guard<T>(input: ResourcePermissionRequest, effect: () => Promise<T> | T, options?: PermissionRequestOptions): Promise<T>;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Shared lifecycle-managed native runtime. `client()` is lazy: acquiring a
|
|
190
|
+
* runtime neither discovers a service nor registers an RPC, so an unused plugin
|
|
191
|
+
* never depends on host service availability. Sharing is scoped to the exact
|
|
192
|
+
* plugin context object, never to a bare cwd.
|
|
193
|
+
*/
|
|
194
|
+
export interface NativeRuntime<Context extends RuntimeContext = RuntimeContext, Client extends RuntimeClient = OpenCodeClient> {
|
|
195
|
+
/** The native plugin context this runtime was acquired from. */
|
|
196
|
+
readonly context: Context;
|
|
197
|
+
/** The native plugin location this runtime is bound to. */
|
|
198
|
+
readonly location: RuntimeLocation;
|
|
199
|
+
/** Stable identity used for diagnostics; equal locations may still differ by context. */
|
|
200
|
+
readonly identity: RuntimeIdentity;
|
|
201
|
+
/** Random per-runtime challenge identity; distinct contexts never share it. */
|
|
202
|
+
readonly instanceId: string;
|
|
203
|
+
/** Lazily discover, authenticate, and challenge the full native client. */
|
|
204
|
+
client(): Promise<Client>;
|
|
205
|
+
/** Resource permission service bound to this runtime's authenticated client. */
|
|
206
|
+
readonly permissions: PermissionService;
|
|
207
|
+
/** Force disposal of runtime-owned registrations and subscriptions. Idempotent. */
|
|
208
|
+
dispose(): Promise<void>;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Per-acquisition release handle. Each `acquireRuntime` call yields its own
|
|
212
|
+
* handle, and releasing the same handle twice never affects another consumer's
|
|
213
|
+
* live runtime.
|
|
214
|
+
*/
|
|
215
|
+
export interface RuntimeLease<Context extends RuntimeContext = RuntimeContext, Client extends RuntimeClient = OpenCodeClient> {
|
|
216
|
+
readonly runtime: NativeRuntime<Context, Client>;
|
|
217
|
+
/** Idempotent for this lease; disposes the runtime only when the last lease releases. */
|
|
218
|
+
release(): Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
/** No compatible already-running service could be discovered. */
|
|
221
|
+
export declare class RuntimeUnavailableError extends Error {
|
|
222
|
+
readonly code = "RUNTIME_UNAVAILABLE";
|
|
223
|
+
constructor();
|
|
224
|
+
}
|
|
225
|
+
/** The discovered service did not prove the loading plugin instance and location. */
|
|
226
|
+
export declare class RuntimeChallengeError extends Error {
|
|
227
|
+
readonly code = "RUNTIME_CHALLENGE_FAILED";
|
|
228
|
+
constructor(reason: string, options?: ErrorOptions);
|
|
229
|
+
}
|
|
230
|
+
/** The runtime was released and can no longer serve work. */
|
|
231
|
+
export declare class RuntimeDisposedError extends Error {
|
|
232
|
+
readonly code = "RUNTIME_DISPOSED";
|
|
233
|
+
constructor();
|
|
234
|
+
}
|
|
235
|
+
/** Concrete native provider/model/variant selection. */
|
|
236
|
+
export interface ModelSelection {
|
|
237
|
+
readonly providerID: string;
|
|
238
|
+
readonly modelID: string;
|
|
239
|
+
readonly variant?: string | undefined;
|
|
240
|
+
}
|
|
241
|
+
/** Persisted model variant overlay materialized as a native model variant. */
|
|
242
|
+
export interface ModelVariantCapture {
|
|
243
|
+
/** Snapshot-qualified native variant id: `<snapshotId>.<modelID>[.<sourceVariant>]`. */
|
|
244
|
+
readonly id: string;
|
|
245
|
+
readonly providerID: string;
|
|
246
|
+
readonly modelID: string;
|
|
247
|
+
/** Source role variant (for example `thinking`) that produced this overlay. */
|
|
248
|
+
readonly sourceVariant?: string | undefined;
|
|
249
|
+
readonly settings?: Readonly<Record<string, unknown>> | undefined;
|
|
250
|
+
readonly body?: Readonly<Record<string, unknown>> | undefined;
|
|
251
|
+
readonly headers?: Readonly<Record<string, string>> | undefined;
|
|
252
|
+
}
|
|
253
|
+
/** Deep-copied, schema-validated effective vvoc configuration captured for replay. */
|
|
254
|
+
export type CapturedVvocConfig = VvocConfig;
|
|
255
|
+
/** Captured native model/provider overlay needed to replay an actual request payload. */
|
|
256
|
+
export interface CapturedModelSettings {
|
|
257
|
+
readonly providerID: string;
|
|
258
|
+
readonly modelID: string;
|
|
259
|
+
readonly variant?: string | undefined;
|
|
260
|
+
readonly settings?: Readonly<Record<string, unknown>> | undefined;
|
|
261
|
+
readonly body?: Readonly<Record<string, unknown>> | undefined;
|
|
262
|
+
readonly headers?: Readonly<Record<string, string>> | undefined;
|
|
263
|
+
}
|
|
264
|
+
/** Provenance of a captured selection: how the effective model was chosen. */
|
|
265
|
+
export type CaptureIntentMode = "explicit" | "implicit" | "staged";
|
|
266
|
+
/** Native source that produced a captured selection. */
|
|
267
|
+
export type CaptureIntentSource = "config" | "switch" | "watcher" | "preset";
|
|
268
|
+
/** Explicit/implicit/staged provenance of a captured selection, with raw role intent preserved. */
|
|
269
|
+
export interface CaptureIntent {
|
|
270
|
+
readonly mode: CaptureIntentMode;
|
|
271
|
+
readonly source: CaptureIntentSource;
|
|
272
|
+
/** Raw vv-role reference when the selection originated from a role binding. */
|
|
273
|
+
readonly roleRef?: string | undefined;
|
|
274
|
+
/** Literal selection when the user or config supplied a concrete provider/model. */
|
|
275
|
+
readonly literal?: ModelSelection | undefined;
|
|
276
|
+
}
|
|
277
|
+
/** Captured agent-to-role and resolved-model binding. */
|
|
278
|
+
export interface AgentPolicyBinding {
|
|
279
|
+
readonly agentID: string;
|
|
280
|
+
readonly role?: string | undefined;
|
|
281
|
+
readonly selection?: ModelSelection | undefined;
|
|
282
|
+
}
|
|
283
|
+
/** Durable immutable policy/model capture bound to one session family. */
|
|
284
|
+
export interface FamilyCapture {
|
|
285
|
+
readonly schemaVersion: 1;
|
|
286
|
+
readonly snapshotId: string;
|
|
287
|
+
/** Content digest over every behavior-relevant capture field, verified on read. */
|
|
288
|
+
readonly integrity: string;
|
|
289
|
+
readonly familyId: string;
|
|
290
|
+
readonly capturedAt: number;
|
|
291
|
+
readonly location: RuntimeIdentity;
|
|
292
|
+
readonly roles: Readonly<Record<string, string>>;
|
|
293
|
+
readonly roleModels: Readonly<Record<string, ModelSelection>>;
|
|
294
|
+
readonly agents: ReadonlyArray<AgentPolicyBinding>;
|
|
295
|
+
readonly variants: ReadonlyArray<ModelVariantCapture>;
|
|
296
|
+
readonly modelSettings: ReadonlyArray<CapturedModelSettings>;
|
|
297
|
+
readonly vvoc: CapturedVvocConfig;
|
|
298
|
+
/** Raw OpenCode root/small_model/agent/command model intent preserved before normalization. */
|
|
299
|
+
readonly rawIntent?: RawOpenCodeModelIntent | undefined;
|
|
300
|
+
/** Implicit root selection from raw OpenCode root model intent, below an explicit choice. */
|
|
301
|
+
readonly rootSelection?: ModelSelection | undefined;
|
|
302
|
+
readonly modelOverride?: ModelSelection | undefined;
|
|
303
|
+
readonly intent: CaptureIntent;
|
|
304
|
+
}
|
|
305
|
+
/** Persisted pre-dispatch admission candidate. */
|
|
306
|
+
export interface StagedCandidate {
|
|
307
|
+
readonly familyId: string;
|
|
308
|
+
/** Session whose awaited switch applied this candidate, used for commit-failure rollback. */
|
|
309
|
+
readonly sessionID: string;
|
|
310
|
+
/**
|
|
311
|
+
* Expected accepted-input identity: the native messageID supplied by the
|
|
312
|
+
* prompt hook. A commit is authorized only by an inbox enqueue with this exact
|
|
313
|
+
* inboxID (or a durable log replay proving it), never by family alone.
|
|
314
|
+
*/
|
|
315
|
+
readonly inboxID?: string | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* Owner token for an owned generated-work operation (for example an auxiliary
|
|
318
|
+
* child or a direct generate). Prompt candidates carry `inboxID`; owned
|
|
319
|
+
* candidates carry `operationID`; the two are never interchangeable.
|
|
320
|
+
*/
|
|
321
|
+
readonly operationID?: string | undefined;
|
|
322
|
+
/** Workload the candidate was staged for (`prompt`, `generate`, ...). */
|
|
323
|
+
readonly workload?: string | undefined;
|
|
324
|
+
readonly stagedAt: number;
|
|
325
|
+
/** Capture content revision the candidate was staged for; a newer revision supersedes it. */
|
|
326
|
+
readonly revision: string;
|
|
327
|
+
/** Fully qualified selection (including captured variant) applied by the awaited switch. */
|
|
328
|
+
readonly selection: ModelSelection;
|
|
329
|
+
/** Session model before the switch, used for conditional rollback. */
|
|
330
|
+
readonly before?: ModelSelection | undefined;
|
|
331
|
+
readonly capture: FamilyCapture;
|
|
332
|
+
}
|
|
333
|
+
/** Durable per-family capture and staged-candidate persistence contract. */
|
|
334
|
+
export interface SnapshotStore {
|
|
335
|
+
read(familyId: string): Promise<FamilyCapture | undefined>;
|
|
336
|
+
write(familyId: string, capture: FamilyCapture): Promise<void>;
|
|
337
|
+
remove(familyId: string): Promise<void>;
|
|
338
|
+
/** All staged candidates for a family, in durable file order. */
|
|
339
|
+
readCandidates(familyId: string): Promise<readonly StagedCandidate[]>;
|
|
340
|
+
/** Insert or update the candidate with the same {@link stagedCandidateKey}. */
|
|
341
|
+
writeCandidate(candidate: StagedCandidate): Promise<void>;
|
|
342
|
+
/** Remove exactly the candidate with this key; leaves other owners intact. */
|
|
343
|
+
removeCandidate(familyId: string, candidateKey: string): Promise<void>;
|
|
344
|
+
/** Remove every staged candidate for a family (used once a family is bound). */
|
|
345
|
+
removeCandidates(familyId: string): Promise<void>;
|
|
346
|
+
/** Durable marker proving a family was once bound, so a missing capture fails closed. */
|
|
347
|
+
readMarker(familyId: string): Promise<boolean>;
|
|
348
|
+
writeMarker(familyId: string): Promise<void>;
|
|
349
|
+
removeMarker(familyId: string): Promise<void>;
|
|
350
|
+
list(): Promise<readonly string[]>;
|
|
351
|
+
}
|
|
352
|
+
/** Stable identity of one staged candidate within a family. */
|
|
353
|
+
export declare function stagedCandidateIdentity(input: {
|
|
354
|
+
readonly sessionID: string;
|
|
355
|
+
readonly inboxID?: string | undefined;
|
|
356
|
+
readonly operationID?: string | undefined;
|
|
357
|
+
readonly workload?: string | undefined;
|
|
358
|
+
}): string;
|
|
359
|
+
/** Stable identity of one staged candidate within a family. */
|
|
360
|
+
export declare function stagedCandidateKey(candidate: StagedCandidate): string;
|
|
361
|
+
/**
|
|
362
|
+
* One native accepted input reconciled from the live stream or the durable
|
|
363
|
+
* session log, with the native ordering signals used to pick the first accepted
|
|
364
|
+
* workload of a family.
|
|
365
|
+
*/
|
|
366
|
+
export interface AcceptedInput {
|
|
367
|
+
readonly sessionID: string;
|
|
368
|
+
readonly inboxID: string;
|
|
369
|
+
readonly itemType: string;
|
|
370
|
+
/** Native event creation time in epoch milliseconds. */
|
|
371
|
+
readonly created: number;
|
|
372
|
+
/** Native per-aggregate durable sequence, when supplied. */
|
|
373
|
+
readonly seq?: number | undefined;
|
|
374
|
+
/** Whether this entry came from a verified live event or the durable log replay. */
|
|
375
|
+
readonly source: "live" | "log";
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Accepted-input reconciliation for one session. `complete` is true only when
|
|
379
|
+
* the durable log replay reached a verified matching synced watermark; an
|
|
380
|
+
* incomplete result may still carry verified live events but must not be used to
|
|
381
|
+
* order multiple candidates.
|
|
382
|
+
*/
|
|
383
|
+
export interface AcceptedInputReconciliation {
|
|
384
|
+
readonly inputs: readonly AcceptedInput[];
|
|
385
|
+
readonly complete: boolean;
|
|
386
|
+
}
|
|
387
|
+
/** Structural native session view used for host-verified lineage and provenance. */
|
|
388
|
+
export interface NativeSessionView {
|
|
389
|
+
readonly id: string;
|
|
390
|
+
readonly parentID?: string | undefined;
|
|
391
|
+
readonly forkSessionID?: string | undefined;
|
|
392
|
+
readonly locationDirectory?: string | undefined;
|
|
393
|
+
readonly model?: ModelSelection | undefined;
|
|
394
|
+
/** Selected agent id, used to resolve agent-specific captured roles. */
|
|
395
|
+
readonly agent?: string | undefined;
|
|
396
|
+
/**
|
|
397
|
+
* Host-persisted session metadata. Auxiliary children record their intended
|
|
398
|
+
* role/kind here so the intended selection is recoverable after a restart
|
|
399
|
+
* without an ephemeral in-process exemption.
|
|
400
|
+
*/
|
|
401
|
+
readonly metadata?: Readonly<Record<string, unknown>> | undefined;
|
|
402
|
+
/** True once the session has produced or received work, so a missing capture is not "fresh". */
|
|
403
|
+
readonly hasActivity?: boolean | undefined;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Structural native model transform editor used for variant materialization. The
|
|
407
|
+
* native `ModelEditor` callback parameter satisfies it exactly, so plugin code
|
|
408
|
+
* passes the native editor without a cast.
|
|
409
|
+
*/
|
|
410
|
+
export interface ModelEditorLike {
|
|
411
|
+
list(providerID?: string): readonly DeepMutable<Model.Info>[];
|
|
412
|
+
get(providerID: string, modelID: string): DeepMutable<Model.Info> | undefined;
|
|
413
|
+
update(providerID: string, modelID: string, update: (model: DeepMutable<Model.Info>) => void): void;
|
|
414
|
+
/** Native default-model handle used to drive future-session provenance. */
|
|
415
|
+
readonly default: {
|
|
416
|
+
get(): {
|
|
417
|
+
readonly providerID: string;
|
|
418
|
+
readonly modelID: string;
|
|
419
|
+
} | undefined;
|
|
420
|
+
set(providerID: string, modelID: string): void;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Structural native agent transform editor used for snapshot-bound role
|
|
425
|
+
* selection. The native `AgentEditor` callback parameter satisfies it exactly.
|
|
426
|
+
*/
|
|
427
|
+
export interface AgentEditorLike {
|
|
428
|
+
list(): readonly DeepMutable<Agent.Info>[];
|
|
429
|
+
get(id: string): DeepMutable<Agent.Info> | undefined;
|
|
430
|
+
update(id: string, update: (agent: DeepMutable<Agent.Info>) => void): void;
|
|
431
|
+
}
|
|
432
|
+
/** Snapshot-qualified variant to publish on one real provider/model. */
|
|
433
|
+
export interface VariantRegistration {
|
|
434
|
+
readonly providerID: string;
|
|
435
|
+
readonly modelID: string;
|
|
436
|
+
readonly variant: ModelVariantCapture;
|
|
437
|
+
}
|
|
438
|
+
/** Result of one awaited family admission or commit attempt. */
|
|
439
|
+
export interface AdmissionOutcome {
|
|
440
|
+
readonly status: "bound" | "staged" | "reused" | "rejected";
|
|
441
|
+
readonly familyId: string;
|
|
442
|
+
readonly snapshotId?: string | undefined;
|
|
443
|
+
readonly candidateSelection?: ModelSelection | undefined;
|
|
444
|
+
readonly rollback?: "reverted" | "preserved-newer-choice" | "none" | undefined;
|
|
445
|
+
readonly error?: string | undefined;
|
|
446
|
+
}
|
|
447
|
+
/** Structural effective vvoc policy input to the snapshot service. */
|
|
448
|
+
export interface EffectiveRuntimeConfig {
|
|
449
|
+
readonly roles: Readonly<Record<string, string>>;
|
|
450
|
+
/** Agent-to-role bindings managed by vvoc for built-in and bundled agents. */
|
|
451
|
+
readonly agentRoles: Readonly<Record<string, string>>;
|
|
452
|
+
/** Full effective vvoc document captured for replay. */
|
|
453
|
+
readonly vvoc: CapturedVvocConfig;
|
|
454
|
+
/** Native agent bindings (including custom agents) observed from the host editor. */
|
|
455
|
+
readonly agentBindings?: ReadonlyArray<AgentPolicyBinding> | undefined;
|
|
456
|
+
/** Native model/provider overlays observed from the host editor. */
|
|
457
|
+
readonly modelSettings?: ReadonlyArray<CapturedModelSettings> | undefined;
|
|
458
|
+
/** Current host default model, used for initial-selection provenance. */
|
|
459
|
+
readonly nativeDefault?: ModelSelection | undefined;
|
|
460
|
+
/** Raw OpenCode model intent preserved before native normalization. */
|
|
461
|
+
readonly rawIntent?: RawOpenCodeModelIntent | undefined;
|
|
462
|
+
/** Implicit root selection resolved from raw OpenCode root model intent. */
|
|
463
|
+
readonly rootDefault?: ModelSelection | undefined;
|
|
464
|
+
readonly sourcePath?: string | undefined;
|
|
465
|
+
}
|
|
466
|
+
/** Per-workload admission request. */
|
|
467
|
+
export interface SnapshotAdmissionRequest {
|
|
468
|
+
readonly sessionID: string;
|
|
469
|
+
readonly directory: string;
|
|
470
|
+
/** Runtime identity of the host location owning this workload. */
|
|
471
|
+
readonly location: RuntimeIdentity;
|
|
472
|
+
/** User's explicit native selection, preserved over any implicit default. */
|
|
473
|
+
readonly explicit?: ModelSelection | undefined;
|
|
474
|
+
/**
|
|
475
|
+
* Base selection to bind when no explicit user choice exists. Used by callers
|
|
476
|
+
* that must bind the session's current model without marking it user-explicit
|
|
477
|
+
* (for example when role overriding is disabled). Falls back to the capture's
|
|
478
|
+
* primary role selection.
|
|
479
|
+
*/
|
|
480
|
+
readonly selectionOverride?: ModelSelection | undefined;
|
|
481
|
+
readonly intent?: CaptureIntent | undefined;
|
|
482
|
+
/** Session model before admission, used for conditional rollback. */
|
|
483
|
+
readonly before?: ModelSelection | undefined;
|
|
484
|
+
/**
|
|
485
|
+
* Expected accepted-input identity for this workload: the native messageID the
|
|
486
|
+
* prompt hook received. Persisted with the candidate and required to match the
|
|
487
|
+
* later `session.inbox.enqueued` before any commit.
|
|
488
|
+
*/
|
|
489
|
+
readonly inboxID?: string | undefined;
|
|
490
|
+
/**
|
|
491
|
+
* Owner token for an owned generated-work operation. Set only by the runtime's
|
|
492
|
+
* own pre-admission gateway; never by a raw external generate.
|
|
493
|
+
*/
|
|
494
|
+
readonly operationID?: string | undefined;
|
|
495
|
+
/** Workload kind the candidate was staged for (`prompt`, `generate`, ...). */
|
|
496
|
+
readonly workload?: string | undefined;
|
|
497
|
+
/**
|
|
498
|
+
* When false, the candidate is persisted and committed but no native model
|
|
499
|
+
* switch is issued. Used when role overriding is disabled so admission records
|
|
500
|
+
* policy without forcing a model change.
|
|
501
|
+
*/
|
|
502
|
+
readonly force?: boolean | undefined;
|
|
503
|
+
/**
|
|
504
|
+
* One immutable admission config assembled by the caller from a single coherent
|
|
505
|
+
* read (fresh vvoc + raw intent + provenance-aware native agent inputs +
|
|
506
|
+
* bindings + overlays). When present the service derives the candidate target
|
|
507
|
+
* and the family capture from this exact value instead of re-reading config,
|
|
508
|
+
* so a concurrent vvoc change cannot make the target and capture disagree.
|
|
509
|
+
*/
|
|
510
|
+
readonly admissionConfig?: EffectiveRuntimeConfig | undefined;
|
|
511
|
+
}
|
|
512
|
+
/** Correlated acceptance input for committing a staged candidate. */
|
|
513
|
+
export interface SnapshotAcceptRequest {
|
|
514
|
+
readonly sessionID: string;
|
|
515
|
+
/** Live enqueued inbox id; when omitted the durable session log is reconciled. */
|
|
516
|
+
readonly inboxID?: string | undefined;
|
|
517
|
+
/** Live item type (`user`/`synthetic`); when omitted the durable log decides. */
|
|
518
|
+
readonly itemType?: string | undefined;
|
|
519
|
+
/** Pre-publication validation; returning false refuses without publishing. */
|
|
520
|
+
readonly validate?: ((selection: ModelSelection) => boolean) | undefined;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Owned generated-work admission request. `operationID` is an operation token the
|
|
524
|
+
* runtime itself minted for this workload; it distinguishes owned generated work
|
|
525
|
+
* from prompt-input candidates and prevents the gateway from publishing a prompt
|
|
526
|
+
* candidate that still needs correlated native acceptance.
|
|
527
|
+
*/
|
|
528
|
+
export type SnapshotOwnedAdmissionRequest = SnapshotAdmissionRequest & {
|
|
529
|
+
readonly operationID: string;
|
|
530
|
+
};
|
|
531
|
+
/** Documented snapshot/config/model/auxiliary service consumed by later plugins. */
|
|
532
|
+
export interface SnapshotService {
|
|
533
|
+
/** Host-verified family root session id for a session. */
|
|
534
|
+
familyOf(sessionID: string): Promise<string>;
|
|
535
|
+
/** Immutable captured policy bound to a session's family, or undefined when unbound. */
|
|
536
|
+
policy(sessionID: string): Promise<FamilyCapture | undefined>;
|
|
537
|
+
/** Immutable snapshot configuration for a session, including full vvoc and native overlays. */
|
|
538
|
+
configFor(sessionID: string): Promise<FamilyCapture | undefined>;
|
|
539
|
+
/** All durable family captures known to this service. */
|
|
540
|
+
captures(): Promise<readonly FamilyCapture[]>;
|
|
541
|
+
/** Snapshot-qualified variants derived from every durable capture, optionally one family. */
|
|
542
|
+
variants(familyId?: string): Promise<readonly VariantRegistration[]>;
|
|
543
|
+
/**
|
|
544
|
+
* Persist a staged candidate and await the native qualified switch; no commit
|
|
545
|
+
* yet. `materialize` runs after the candidate selection is known and before the
|
|
546
|
+
* switch, so the catalog carries the variant the resolved request will use.
|
|
547
|
+
*/
|
|
548
|
+
stage(request: SnapshotAdmissionRequest, materialize?: (capture: FamilyCapture, selection: ModelSelection, candidateIdentity: string) => Promise<void>): Promise<AdmissionOutcome>;
|
|
549
|
+
/**
|
|
550
|
+
* Commit a stage only when workload-correlated acceptance is proven. `inboxID`/
|
|
551
|
+
* `itemType` come from a live `session.inbox.enqueued`; when omitted the service
|
|
552
|
+
* reconciles through the durable session log and fails closed unless a genuine
|
|
553
|
+
* synced watermark proves the replay complete. An explicit `validate` runs
|
|
554
|
+
* before publication so a mismatched resolved model never publishes a capture.
|
|
555
|
+
* Refuses owned candidates; those belong to `admitOwned`.
|
|
556
|
+
*/
|
|
557
|
+
accept(input: SnapshotAcceptRequest): Promise<AdmissionOutcome>;
|
|
558
|
+
/** True when a candidate is staged for the family. */
|
|
559
|
+
hasStaged(familyId: string): Promise<boolean>;
|
|
560
|
+
/**
|
|
561
|
+
* Owned generated-work gateway: stage with the runtime-minted operation token,
|
|
562
|
+
* materialize the qualified variant, switch, and publish before native model
|
|
563
|
+
* resolution. It never publishes a prompt candidate and refuses when the staged
|
|
564
|
+
* candidate is no longer owned by `operationID`.
|
|
565
|
+
*/
|
|
566
|
+
admitOwned(request: SnapshotOwnedAdmissionRequest, materialize?: (capture: FamilyCapture, selection: ModelSelection, candidateIdentity: string) => Promise<void>): Promise<AdmissionOutcome>;
|
|
567
|
+
/** Snapshot-bound auxiliary generation for title and Guardian work. */
|
|
568
|
+
readonly auxiliary: AuxiliaryService;
|
|
569
|
+
/** Release service-owned state; never stops the host. */
|
|
570
|
+
dispose(): void;
|
|
571
|
+
}
|
|
572
|
+
/** Per-acquisition release handle for a shared snapshot service. */
|
|
573
|
+
export interface SnapshotLease {
|
|
574
|
+
readonly snapshots: SnapshotService;
|
|
575
|
+
/** Idempotent for this lease; disposes the service only when the last lease releases. */
|
|
576
|
+
release(): Promise<void>;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Structural native auxiliary-session/generate boundary. Production creates a
|
|
580
|
+
* real parented native child through the authenticated full client's
|
|
581
|
+
* `session.import` (an imported session with a parentID, not a fork that copies
|
|
582
|
+
* the parent agent or the plugin subset's parentless `session.create`).
|
|
583
|
+
*/
|
|
584
|
+
export interface AuxiliarySessionApi {
|
|
585
|
+
create(input: {
|
|
586
|
+
/** Family root the imported child is parented to; `get(child).parentID` must equal it. */
|
|
587
|
+
readonly parentID: string;
|
|
588
|
+
/** Directory the child is created in; reused from the family root. */
|
|
589
|
+
readonly locationDirectory: string;
|
|
590
|
+
/** Nonempty child title. */
|
|
591
|
+
readonly title: string;
|
|
592
|
+
/** Workload kind recorded in host-owned metadata for restart recovery. */
|
|
593
|
+
readonly kind: "title" | "compaction" | "generate";
|
|
594
|
+
/** Captured role whose selection the child is bound to, when known. */
|
|
595
|
+
readonly role?: string | undefined;
|
|
596
|
+
/** Fully qualified family selection applied to the child. */
|
|
597
|
+
readonly model: ModelSelection;
|
|
598
|
+
/** Optional captured agent id to bind. */
|
|
599
|
+
readonly agent?: string | undefined;
|
|
600
|
+
}): Promise<{
|
|
601
|
+
readonly sessionID: string;
|
|
602
|
+
}>;
|
|
603
|
+
switchModel(input: {
|
|
604
|
+
readonly sessionID: string;
|
|
605
|
+
readonly model: ModelSelection;
|
|
606
|
+
}): Promise<void>;
|
|
607
|
+
generate(input: {
|
|
608
|
+
readonly sessionID: string;
|
|
609
|
+
readonly prompt: string;
|
|
610
|
+
}): Promise<{
|
|
611
|
+
readonly text: string;
|
|
612
|
+
}>;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Host-owned metadata recorded on an auxiliary child so its intended role and
|
|
616
|
+
* selection are recoverable after restart without a model-only exemption.
|
|
617
|
+
*/
|
|
618
|
+
export interface AuxiliaryWorkloadMetadata {
|
|
619
|
+
readonly kind: "title" | "compaction" | "generate";
|
|
620
|
+
readonly role?: string | undefined;
|
|
621
|
+
}
|
|
622
|
+
/** Decode the auxiliary workload metadata embedded in native session metadata. */
|
|
623
|
+
export declare function decodeAuxiliaryMetadata(metadata: Readonly<Record<string, unknown>> | undefined): AuxiliaryWorkloadMetadata | undefined;
|
|
624
|
+
/** Typed payload forwarded to the native import route for a parented auxiliary child. */
|
|
625
|
+
export interface NativeSessionImportPayload {
|
|
626
|
+
readonly info: {
|
|
627
|
+
readonly id: string;
|
|
628
|
+
readonly parentID: string;
|
|
629
|
+
readonly projectID: string;
|
|
630
|
+
readonly agent?: string | undefined;
|
|
631
|
+
readonly model?: {
|
|
632
|
+
readonly id: string;
|
|
633
|
+
readonly providerID: string;
|
|
634
|
+
readonly variant?: string;
|
|
635
|
+
} | undefined;
|
|
636
|
+
readonly cost: number;
|
|
637
|
+
readonly tokens: {
|
|
638
|
+
readonly input: number;
|
|
639
|
+
readonly output: number;
|
|
640
|
+
readonly reasoning: number;
|
|
641
|
+
readonly cache: {
|
|
642
|
+
readonly read: number;
|
|
643
|
+
readonly write: number;
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
readonly time: {
|
|
647
|
+
readonly created: number;
|
|
648
|
+
readonly updated: number;
|
|
649
|
+
};
|
|
650
|
+
readonly title: string;
|
|
651
|
+
readonly location: {
|
|
652
|
+
readonly directory: string;
|
|
653
|
+
};
|
|
654
|
+
readonly metadata?: Readonly<Record<string, unknown>> | undefined;
|
|
655
|
+
readonly permissions?: ReadonlyArray<{
|
|
656
|
+
readonly action: string;
|
|
657
|
+
readonly resource: string;
|
|
658
|
+
readonly effect: "allow" | "deny" | "ask";
|
|
659
|
+
}> | undefined;
|
|
660
|
+
};
|
|
661
|
+
readonly messages: ReadonlyArray<unknown>;
|
|
662
|
+
readonly location: {
|
|
663
|
+
readonly directory: string;
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
/** Decode the id of an imported native session from the unchecked client result. */
|
|
667
|
+
export declare function decodeImportedSessionID(value: unknown): string | undefined;
|
|
668
|
+
/** Text carried by a native title request, retained as generation input. */
|
|
669
|
+
export interface AuxiliaryMessageContent {
|
|
670
|
+
readonly role: string;
|
|
671
|
+
readonly text: string;
|
|
672
|
+
}
|
|
673
|
+
/** Snapshot-bound auxiliary generation consumed by title and Guardian. */
|
|
674
|
+
export interface AuxiliaryService {
|
|
675
|
+
/** Resolve a title through a bound child; a set event.result always wins. */
|
|
676
|
+
title(event: {
|
|
677
|
+
readonly sessionID: string;
|
|
678
|
+
result?: string | undefined;
|
|
679
|
+
/** Native title messages retained as generation input, never dropped. */
|
|
680
|
+
readonly messages?: ReadonlyArray<AuxiliaryMessageContent> | undefined;
|
|
681
|
+
/** Captured role to use (title/small_model), never an implicit primary fallback. */
|
|
682
|
+
readonly role?: string | undefined;
|
|
683
|
+
}): Promise<string | undefined>;
|
|
684
|
+
/** Run snapshot-bound auxiliary generation for the given request kind and role. */
|
|
685
|
+
generate(input: {
|
|
686
|
+
readonly sessionID: string;
|
|
687
|
+
readonly kind: "title" | "compaction" | "generate";
|
|
688
|
+
readonly prompt: string;
|
|
689
|
+
/** Captured role to use (for example Guardian's fast role); defaults to primary. */
|
|
690
|
+
readonly role?: string | undefined;
|
|
691
|
+
}): Promise<{
|
|
692
|
+
readonly text: string;
|
|
693
|
+
} | undefined>;
|
|
694
|
+
}
|
|
695
|
+
/** Durable capture state was corrupt or unreadable, so work must fail closed. */
|
|
696
|
+
export declare class SnapshotStoreError extends Error {
|
|
697
|
+
readonly code = "SNAPSHOT_STORE_INVALID";
|
|
698
|
+
constructor(message: string, options?: ErrorOptions);
|
|
699
|
+
}
|
|
700
|
+
/** An awaited admission failed and no policy was published. */
|
|
701
|
+
export declare class SnapshotAdmissionError extends Error {
|
|
702
|
+
readonly code = "SNAPSHOT_ADMISSION_FAILED";
|
|
703
|
+
constructor(message: string, options?: ErrorOptions);
|
|
704
|
+
}
|
|
705
|
+
/** A dispatch was refused because no family policy was bound. */
|
|
706
|
+
export declare class SnapshotUnboundError extends Error {
|
|
707
|
+
readonly code = "SNAPSHOT_UNBOUND";
|
|
708
|
+
constructor(message?: string);
|
|
709
|
+
}
|
|
710
|
+
/** Build the stable identity from a runtime location. */
|
|
711
|
+
export declare function runtimeIdentity(location: RuntimeLocation): RuntimeIdentity;
|
|
712
|
+
/** Render a deterministic location identity string for diagnostics. */
|
|
713
|
+
export declare function runtimeKey(identity: RuntimeIdentity): string;
|