@mininglamp-oss/octo-runtime 1.1.10 → 1.1.11

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 (170) hide show
  1. package/README.md +1 -1
  2. package/apps/cli/README.md +1 -1
  3. package/apps/cli/dist/adapters.js +40 -14
  4. package/apps/cli/dist/build-info.json +2 -2
  5. package/apps/cli/dist/command-tree.js +2 -3
  6. package/apps/cli/dist/extras.js +11 -1
  7. package/apps/cli/dist/index.js +14 -1
  8. package/apps/cli/dist/main.js +58 -23
  9. package/apps/cli/dist/module-manifest.js +21 -3
  10. package/apps/cli/dist/output.d.ts +19 -1
  11. package/apps/cli/dist/output.js +179 -27
  12. package/apps/cli/dist/playboard.js +2 -2
  13. package/apps/cli/dist/state.d.ts +5 -2
  14. package/apps/cli/dist/state.js +48 -13
  15. package/dist/public/codex.d.ts +1 -0
  16. package/dist/public/codex.js +1 -0
  17. package/dist/public/executor-kernel.d.ts +4 -0
  18. package/dist/public/executor-kernel.js +2 -0
  19. package/dist/public/extra.d.ts +1 -1
  20. package/dist/public/host.d.ts +5 -0
  21. package/dist/public/host.js +2 -0
  22. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +20 -0
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  25. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  26. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  27. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  28. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -6
  29. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +68 -253
  30. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +11 -6
  31. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +198 -52
  32. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +58 -0
  33. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +650 -0
  34. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +3 -0
  35. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +15 -0
  36. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  37. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  38. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  39. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  40. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  42. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  43. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +2 -0
  44. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  45. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  46. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  47. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -0
  48. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +25 -0
  49. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.js +1 -0
  50. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -0
  51. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  52. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +40 -14
  53. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  54. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +2 -3
  55. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +11 -1
  56. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +14 -1
  57. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +58 -23
  58. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +21 -3
  59. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +19 -1
  60. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +179 -27
  61. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +2 -2
  62. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +5 -2
  63. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -13
  64. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -23
  65. package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +5 -0
  66. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.d.ts +30 -0
  67. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.js +199 -0
  68. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.d.ts +1 -0
  69. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.js +1 -0
  70. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.d.ts +10 -0
  71. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +465 -0
  72. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.d.ts +6 -0
  73. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.js +6 -0
  74. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.d.ts +4 -0
  75. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.js +5 -0
  76. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.d.ts +59 -0
  77. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.js +287 -0
  78. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.d.ts +1 -0
  79. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.js +1 -0
  80. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.d.ts +1 -0
  81. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.js +1 -0
  82. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.d.ts +21 -0
  83. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.js +138 -0
  84. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.d.ts +8 -0
  85. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.js +65 -0
  86. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.d.ts +82 -0
  87. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.js +371 -0
  88. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.d.ts +10 -0
  89. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.js +23 -0
  90. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.d.ts +72 -0
  91. package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.js +10 -0
  92. package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +54 -0
  93. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +1219 -0
  94. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +5988 -0
  95. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +56 -0
  96. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc-fixtures.json +53 -0
  97. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +538 -0
  98. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +116 -0
  99. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +4525 -0
  100. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +761 -0
  101. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +663 -0
  102. package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +191 -0
  103. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  104. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +26 -18
  105. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +151 -11
  106. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  107. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +1 -30
  108. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +2 -199
  109. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +1 -10
  110. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -446
  111. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/endpoint.js +2 -0
  112. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +2 -0
  113. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +13 -2
  114. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +4 -1
  115. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +4 -1
  116. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.d.ts +1 -53
  117. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -280
  118. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.d.ts +5 -10
  119. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.js +4 -1
  120. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.d.ts +20 -0
  121. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.js +180 -0
  122. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +31 -8
  123. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +5 -2
  124. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +48 -5
  125. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.d.ts +1 -0
  126. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.js +1 -0
  127. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts +1 -0
  128. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.js +1 -0
  129. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.d.ts +4 -0
  130. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.js +18 -0
  131. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +1 -10
  132. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +2 -23
  133. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.d.ts +2 -72
  134. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.js +2 -10
  135. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -4
  136. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +1 -1
  137. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/ports.d.ts +2 -2
  138. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  139. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +1 -1
  140. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/ports.d.ts +2 -2
  141. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  142. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +4 -4
  143. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  144. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +1 -1
  145. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +12 -5
  146. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.d.ts +5 -1
  147. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.js +9 -0
  148. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.d.ts +44 -0
  149. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.js +207 -0
  150. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +23 -3
  151. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.d.ts +27 -4
  152. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +133 -25
  153. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.d.ts +10 -3
  154. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.js +18 -4
  155. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.d.ts +5 -6
  156. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +33 -45
  157. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/identity.js +6 -0
  158. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +4 -0
  159. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +3 -0
  160. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +5 -4
  161. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
  162. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.js +1 -0
  163. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +19 -0
  164. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -1
  165. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
  166. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
  167. package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
  168. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  169. package/package.json +33 -27
  170. package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -0
@@ -0,0 +1,44 @@
1
+ import type { AgentExecutor, HostedAdapterMetadata } from "@mininglamp-oss/octo-runtime-executor-core";
2
+ import { type KernelClient } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
+ import { type InputInvoke, type InteractionResponse, type NativeInteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
4
+ /** 宿主显式选择执行位置;direct 始终借用同一 Core,ipc 只连接已有服务。 */
5
+ export type ExtraExecution = {
6
+ kind: "direct";
7
+ executor: AgentExecutor;
8
+ endpoint?: never;
9
+ } | {
10
+ kind: "ipc";
11
+ endpoint: string;
12
+ executor?: never;
13
+ };
14
+ /** Extra 只控制本 scope 的调用;不暴露执行器 shutdown 或 Kernel 的低层恢复原语。 */
15
+ export interface ExtraExecutionContext {
16
+ readonly kind: "direct" | "ipc";
17
+ readonly invoke: InputInvoke;
18
+ cancelInvocation(id: string, reason?: string): Promise<{
19
+ accepted: boolean;
20
+ }>;
21
+ respondInteraction(id: string, response: InteractionResponse): Promise<void>;
22
+ respondNativeInteraction(id: string, response: NativeInteractionResponse): Promise<void>;
23
+ list(): Promise<HostedAdapterMetadata[]>;
24
+ }
25
+ export interface ExtraExecutionScope {
26
+ context: ExtraExecutionContext;
27
+ available(): Promise<boolean>;
28
+ stopAdmission(): void;
29
+ drain(options: {
30
+ deadline: number;
31
+ reason: string;
32
+ }): Promise<{
33
+ complete: boolean;
34
+ }>;
35
+ release(): Promise<void>;
36
+ }
37
+ /** 复用同一 IPC client 的登记、取消重试及恢复逻辑,不复制协议实现。 */
38
+ export declare function ipcExecutionContext(client: KernelClient): ExtraExecutionContext;
39
+ export declare function createIpcExecutionScope(client: KernelClient): ExtraExecutionScope;
40
+ /**
41
+ * 将 Core 的执行 iterator 留在共享有界源中独立驱动;插件只有观察视图。
42
+ * 完整接纳凭据到达前只操作自己的 signal,绝不凭调用方传入的 id 取消共享 Core。
43
+ */
44
+ export declare function createDirectExecutionScope(executor: AgentExecutor): ExtraExecutionScope;
@@ -0,0 +1,207 @@
1
+ import { setTimeout as delay } from "node:timers/promises";
2
+ import { HostRunService, KernelError, admissionClosedError } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
+ import { createInputInvoke, identifyInvokeInput, assertInvokeRequestSize, isHostTerminal } from "@mininglamp-oss/octo-runtime-protocol";
4
+ /** 复用同一 IPC client 的登记、取消重试及恢复逻辑,不复制协议实现。 */
5
+ export function ipcExecutionContext(client) {
6
+ return Object.freeze({
7
+ kind: "ipc",
8
+ invoke: client.invoke,
9
+ cancelInvocation: (id, reason) => client.cancelInvocation(id, reason),
10
+ respondInteraction: (id, response) => client.respondInteraction(id, response),
11
+ respondNativeInteraction: (id, response) => client.respondNativeInteraction(id, response),
12
+ list: () => client.list()
13
+ });
14
+ }
15
+ export function createIpcExecutionScope(client) {
16
+ return {
17
+ context: ipcExecutionContext(client),
18
+ available: () => client.status().then((status) => status.execution_ready, () => false),
19
+ stopAdmission: () => client.invocations.stopAdmission(),
20
+ drain: (options) => client.invocations.drain(options),
21
+ release() {
22
+ client.close();
23
+ return Promise.resolve();
24
+ }
25
+ };
26
+ }
27
+ // 只协调显式共享同一对象的 scope;缓冲总额不随 Extra 数量倍增,不创建全局执行器。
28
+ const coordinators = new WeakMap();
29
+ /**
30
+ * 将 Core 的执行 iterator 留在共享有界源中独立驱动;插件只有观察视图。
31
+ * 完整接纳凭据到达前只操作自己的 signal,绝不凭调用方传入的 id 取消共享 Core。
32
+ */
33
+ export function createDirectExecutionScope(executor) {
34
+ let coordinator = coordinators.get(executor);
35
+ if (!coordinator) {
36
+ coordinator = {
37
+ users: 0,
38
+ source: new HostRunService({
39
+ invoke: executor.invoke,
40
+ invokeFrames: (input, environment) => executor.invokeFrames(input, environment),
41
+ list: (configurations) => executor.describe(configurations),
42
+ probe: (type, options) => Promise.resolve(executor.probe(type, options)),
43
+ cancel: (id, reason) => Promise.resolve({ cancelled: executor.cancel(id, reason) }),
44
+ respondInteraction: (id, response) => executor.respondInteraction(id, response),
45
+ respondNative: (id, response) => executor.respondNative(id, response)
46
+ })
47
+ };
48
+ coordinators.set(executor, coordinator);
49
+ }
50
+ const shared = coordinator;
51
+ shared.users++;
52
+ const records = new Map();
53
+ const queries = new Set();
54
+ let stopped = false;
55
+ let released = false;
56
+ let draining;
57
+ const assertOpen = () => {
58
+ if (stopped)
59
+ throw admissionClosedError();
60
+ if (!executor.status().available)
61
+ throw new Error("EXECUTOR_CLOSED");
62
+ };
63
+ const owned = (id) => {
64
+ const record = records.get(id);
65
+ if (!record)
66
+ throw new KernelError("INVOCATION_NOT_TRACKED");
67
+ return record;
68
+ };
69
+ const accepted = (id) => {
70
+ const record = owned(id);
71
+ if (!record.receipt)
72
+ throw new KernelError("INVOCATION_NOT_ACCEPTED");
73
+ if (record.failed)
74
+ throw new KernelError("RUN_OUTCOME_UNKNOWN");
75
+ return record.receipt;
76
+ };
77
+ const trackQuery = (pending) => {
78
+ queries.add(pending);
79
+ void pending.then(() => queries.delete(pending), () => queries.delete(pending));
80
+ };
81
+ const cancel = async (id, reason = "caller_cancelled") => {
82
+ const record = owned(id);
83
+ if (!record.receipt) {
84
+ record.controller.abort(reason);
85
+ // 明确拒绝接纳不会取得他人的控制权;已接纳则由此 signal 定向通知同一次调用。
86
+ await record.admitted;
87
+ return { accepted: true };
88
+ }
89
+ const receipt = accepted(id);
90
+ if (shared.source.get(receipt.run_id).terminal)
91
+ return { accepted: false };
92
+ return { accepted: executor.cancel(receipt.invocation_id, reason) };
93
+ };
94
+ async function* observe(input, environment = {}) {
95
+ assertOpen();
96
+ environment.signal?.throwIfAborted();
97
+ assertInvokeRequestSize(input, environment);
98
+ const identified = identifyInvokeInput(structuredClone(input));
99
+ if (records.has(identified.invocationId))
100
+ throw new KernelError("EXECUTION_IDENTITY_CONFLICT");
101
+ if (records.size >= 128)
102
+ throw new KernelError("CLIENT_INVOCATION_CAPACITY_EXHAUSTED");
103
+ const controller = new AbortController();
104
+ const abort = () => controller.abort(environment.signal?.reason);
105
+ environment.signal?.addEventListener("abort", abort, { once: true });
106
+ const admitted = shared.source.submit(identified, {
107
+ ...environment,
108
+ ...(environment.executionEnvOverrides
109
+ ? { executionEnvOverrides: structuredClone(environment.executionEnvOverrides) }
110
+ : {}),
111
+ signal: controller.signal
112
+ });
113
+ const record = {
114
+ controller,
115
+ admitted,
116
+ settled: Promise.resolve(),
117
+ failed: false
118
+ };
119
+ records.set(identified.invocationId, record);
120
+ record.settled = admitted
121
+ .then(async (receipt) => {
122
+ record.receipt = receipt;
123
+ await shared.source.settled(receipt);
124
+ const cleanup = await executor.waitForInvocationCleanup(receipt);
125
+ if (cleanup !== "complete")
126
+ throw new Error("EXTRA_RUN_CLEANUP_INCOMPLETE");
127
+ records.delete(identified.invocationId);
128
+ })
129
+ .catch(() => {
130
+ // submit 明确拒绝时未创建 Core owner;已接纳的失败必须保留容量和关闭失败事实。
131
+ if (!record.receipt)
132
+ records.delete(identified.invocationId);
133
+ else
134
+ record.failed = true;
135
+ })
136
+ .finally(() => environment.signal?.removeEventListener("abort", abort));
137
+ const receipt = await admitted;
138
+ let after = 0;
139
+ while (true) {
140
+ const window = shared.source.read(receipt.run_id, receipt.stream_id, after);
141
+ for (const item of window.events) {
142
+ after = item.seq;
143
+ yield item.event;
144
+ if (isHostTerminal(item.event)) {
145
+ if (item.event.kind === "control" &&
146
+ item.event.control.type === "state" &&
147
+ item.event.control.state === "lost")
148
+ throw new KernelError("RUN_OUTCOME_UNKNOWN");
149
+ return;
150
+ }
151
+ }
152
+ // 每次只读取中央窗口的一小批;观察退出不关闭 source,也不撤销已接纳调用。
153
+ await delay(10);
154
+ }
155
+ }
156
+ const context = Object.freeze({
157
+ kind: "direct",
158
+ invoke: createInputInvoke(observe),
159
+ cancelInvocation: cancel,
160
+ respondInteraction: async (id, response) => {
161
+ const receipt = accepted(id);
162
+ await shared.source.respond(receipt.run_id, response);
163
+ },
164
+ respondNativeInteraction: async (id, response) => {
165
+ const receipt = accepted(id);
166
+ await shared.source.respondNativeRun(receipt.run_id, response);
167
+ },
168
+ list: async () => {
169
+ assertOpen();
170
+ if (queries.size >= 128)
171
+ throw new Error("EXTRA_QUERY_CAPACITY_EXHAUSTED");
172
+ const query = executor.describe({}, { onProbe: trackQuery });
173
+ trackQuery(query);
174
+ return query;
175
+ }
176
+ });
177
+ return {
178
+ context,
179
+ available: () => Promise.resolve(!stopped && executor.status().available),
180
+ stopAdmission() {
181
+ stopped = true;
182
+ },
183
+ drain({ deadline, reason }) {
184
+ stopped = true;
185
+ return (draining ??= (async () => {
186
+ for (const [id] of records)
187
+ void cancel(id, reason).catch(() => undefined);
188
+ while ([...records.values()].some((record) => !record.failed) || queries.size) {
189
+ if (Date.now() >= deadline)
190
+ return { complete: false };
191
+ await delay(Math.min(10, Math.max(1, deadline - Date.now())));
192
+ }
193
+ return { complete: records.size === 0 };
194
+ })());
195
+ },
196
+ async release() {
197
+ stopped = true;
198
+ if (released || records.size || queries.size)
199
+ return;
200
+ released = true;
201
+ if (--shared.users === 0) {
202
+ coordinators.delete(executor);
203
+ await shared.source.close();
204
+ }
205
+ }
206
+ };
207
+ }
@@ -2,6 +2,7 @@ import { constants } from "node:fs";
2
2
  import { lstat, open, readdir } from "node:fs/promises";
3
3
  import { isAbsolute, join } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
+ import { withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
5
6
  import { assertExtraName } from "./extras.js";
6
7
  export function assertStoredExtra(value) {
7
8
  if (!value || typeof value !== "object" || Array.isArray(value))
@@ -44,7 +45,13 @@ export function extraRegistration(descriptor) {
44
45
  module,
45
46
  config: stored.config,
46
47
  enabled: stored.enabled,
47
- load: () => import(isAbsolute(module) ? pathToFileURL(module).href : module)
48
+ load: () => import(isAbsolute(module) ? pathToFileURL(module).href : module).catch((error) => {
49
+ throw withStartupContext(error, {
50
+ component: name,
51
+ phase: "created",
52
+ context: { module, resource: "extra-module", operation: "import", configKey: "module" }
53
+ });
54
+ })
48
55
  };
49
56
  }
50
57
  /** Called only by a host that explicitly selects this directory as its source. */
@@ -76,7 +83,7 @@ export async function readExtraDirectory(directory) {
76
83
  registrations.push({
77
84
  name: entry.name,
78
85
  config: {},
79
- load: () => Promise.reject(new Error(code))
86
+ load: () => Promise.reject(new Error(code, { cause: error }))
80
87
  });
81
88
  }
82
89
  }
@@ -86,7 +93,13 @@ export async function readExtraDirectory(directory) {
86
93
  export async function readStoredExtra(directory, name) {
87
94
  assertExtraName(name);
88
95
  const file = join(directory, name, "config.json");
89
- const handle = await open(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
96
+ const handle = await open(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)).catch((error) => {
97
+ throw withStartupContext(error, {
98
+ component: name,
99
+ phase: "created",
100
+ context: { path: file, resource: "extra-config", operation: "open", configKey: "config" }
101
+ });
102
+ });
90
103
  try {
91
104
  // 权限、大小和读取绑定同一个文件,不允许检查后换成链接或其他目标。
92
105
  const info = await handle.stat();
@@ -114,6 +127,13 @@ export async function readStoredExtra(directory, name) {
114
127
  assertStoredExtra(stored);
115
128
  return stored;
116
129
  }
130
+ catch (error) {
131
+ throw withStartupContext(error, {
132
+ component: name,
133
+ phase: "created",
134
+ context: { path: file, resource: "extra-config", operation: "read", configKey: "config" }
135
+ });
136
+ }
117
137
  finally {
118
138
  await handle.close();
119
139
  }
@@ -1,8 +1,8 @@
1
1
  import { type RuntimeLoggingOptions } from "@mininglamp-oss/octo-runtime-adapter-sdk";
2
2
  import { type ServiceLifecycle, type ServicePhase } from "@mininglamp-oss/octo-runtime-executor-kernel";
3
3
  import { type ExtraPluginModule, type JsonObject } from "./extras.js";
4
- export interface ExtraServiceOptions<D extends object = Record<string, never>> {
5
- endpoint: string;
4
+ import { type ExtraExecution } from "./execution.js";
5
+ interface ExtraServiceCommonOptions<D extends object> {
6
6
  module: ExtraPluginModule<D>;
7
7
  config: JsonObject;
8
8
  dependencies: Readonly<D>;
@@ -10,13 +10,36 @@ export interface ExtraServiceOptions<D extends object = Record<string, never>> {
10
10
  controlEndpoint?: string;
11
11
  logging?: RuntimeLoggingOptions;
12
12
  }
13
+ /** IPC/legacy 继续校验宿主 Home;direct 可以完全不配置 Home 和控制端点。 */
14
+ export type ExtraServiceOptions<D extends object = Record<string, never>> = ExtraServiceCommonOptions<D> & ({
15
+ execution: Extract<ExtraExecution, {
16
+ kind: "direct";
17
+ }>;
18
+ endpoint?: never;
19
+ home?: string;
20
+ } | {
21
+ execution: Extract<ExtraExecution, {
22
+ kind: "ipc";
23
+ }>;
24
+ endpoint?: never;
25
+ home: string;
26
+ } | {
27
+ execution?: never;
28
+ endpoint: string;
29
+ home: string;
30
+ });
13
31
  export interface ExtraServiceStatus {
14
32
  phase: ServicePhase;
15
33
  name: string;
16
34
  pid: number;
17
- kernel_available: boolean;
35
+ execution: {
36
+ kind: "direct" | "ipc";
37
+ available: boolean;
38
+ };
39
+ kernel_available?: boolean;
18
40
  plugin: JsonObject;
19
41
  }
20
42
  export type ExtraService = ServiceLifecycle<ExtraServiceStatus>;
21
- /** 装配插件和同进程业务函数;只借用指定 Kernel,不启动或关闭它。 */
43
+ /** 装配插件与独立调用 scope;只借用宿主的 Core 或既有 Kernel,关闭不接管执行服务。 */
22
44
  export declare function createExtraService<D extends object>(options: ExtraServiceOptions<D>): ExtraService;
45
+ export {};
@@ -1,27 +1,77 @@
1
1
  import net from "node:net";
2
+ import { AgentExecutor } from "@mininglamp-oss/octo-runtime-executor-core";
2
3
  import { performance } from "node:perf_hooks";
3
- import { chmod, mkdir, rm } from "node:fs/promises";
4
+ import { chmod, rm } from "node:fs/promises";
4
5
  import { dirname, resolve } from "node:path";
5
- import { RuntimeLogging, assertRuntimeLogging, readBoundedLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
6
- import { acquireEndpoint, attachKernel, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
6
+ import { RuntimeLogging, readBoundedLines } from "@mininglamp-oss/octo-runtime-adapter-sdk";
7
+ import { assertStartupLogging, acquireEndpoint, assertIpcEndpoint, assertRuntimePath, validateRuntimeHome, prepareHomeDirectory, runtimePathFailure, attachKernel, ServiceInitializationError, withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
7
8
  import { assertExtraName, ExtraPlugins } from "./extras.js";
8
9
  import { shutdownDeadline, withShutdownDeadline, withinShutdown } from "./shutdown.js";
9
10
  import { snapshotExtraDependencies } from "./extra-dependencies.js";
11
+ import { createDirectExecutionScope, createIpcExecutionScope } from "./execution.js";
10
12
  // 未确认清理的实例仍占有名称;不同 Kernel/Home 的同名 Extra 相互独立。
11
13
  const owners = new Map();
12
- /** 装配插件和同进程业务函数;只借用指定 Kernel,不启动或关闭它。 */
14
+ const directOwners = new WeakMap();
15
+ let ownerCount = 0;
16
+ /** 装配插件与独立调用 scope;只借用宿主的 Core 或既有 Kernel,关闭不接管执行服务。 */
13
17
  export function createExtraService(options) {
18
+ try {
19
+ return constructExtraService(options);
20
+ }
21
+ catch (error) {
22
+ throw withStartupContext(error, {
23
+ component: "extra",
24
+ phase: "created",
25
+ context: { operation: "validate-options", resource: "extra" }
26
+ });
27
+ }
28
+ }
29
+ function constructExtraService(options) {
30
+ // 以字段存在性拒绝混用,显式 undefined 不能绕过互斥;保存 executor 原对象身份。
31
+ let execution;
32
+ if ("execution" in options) {
33
+ if ("endpoint" in options)
34
+ throw new TypeError("EXTRA_EXECUTION_MIXED");
35
+ const value = options.execution;
36
+ if (!value || typeof value !== "object" || Array.isArray(value))
37
+ throw new TypeError("EXTRA_EXECUTION_INVALID");
38
+ if (value.kind === "direct") {
39
+ if ("endpoint" in value || !(value.executor instanceof AgentExecutor))
40
+ throw new TypeError("EXTRA_EXECUTOR_INVALID: use the AgentExecutor exported by the same Runtime installation");
41
+ execution = { kind: "direct", executor: value.executor };
42
+ }
43
+ else if (value.kind === "ipc") {
44
+ if ("executor" in value || typeof value.endpoint !== "string" || !value.endpoint)
45
+ throw new TypeError("EXTRA_EXECUTION_INVALID");
46
+ execution = { kind: "ipc", endpoint: value.endpoint };
47
+ }
48
+ else
49
+ throw new TypeError("EXTRA_EXECUTION_INVALID");
50
+ }
51
+ else {
52
+ if (typeof options.endpoint !== "string" || !options.endpoint)
53
+ throw new TypeError("EXTRA_EXECUTION_REQUIRED");
54
+ execution = { kind: "ipc", endpoint: options.endpoint };
55
+ }
14
56
  assertExtraName(options.module.name);
15
- assertRuntimeLogging(options.logging);
57
+ assertStartupLogging(options.logging, { component: options.module.name, phase: "created" });
16
58
  const name = options.module.name;
17
59
  const config = structuredClone(options.config);
18
60
  const module = { ...options.module };
19
61
  const pendingDependencies = new Set();
20
- const endpoint = options.endpoint;
62
+ const endpoint = execution.kind === "ipc" ? execution.endpoint : undefined;
63
+ const home = options.home;
21
64
  const controlEndpoint = options.controlEndpoint;
22
65
  const enabled = options.enabled !== false;
23
66
  const logging = options.logging && { ...options.logging };
24
- const key = `${process.platform === "win32" ? endpoint.toLowerCase() : resolve(endpoint)}\0${name}`;
67
+ let ownerships = owners;
68
+ if (execution.kind === "direct") {
69
+ ownerships = directOwners.get(execution.executor) ?? new Map();
70
+ directOwners.set(execution.executor, ownerships);
71
+ }
72
+ const key = endpoint === undefined
73
+ ? name
74
+ : `${process.platform === "win32" ? endpoint.toLowerCase() : resolve(endpoint)}\0${name}`;
25
75
  const owner = new AbortController();
26
76
  let dependenciesOpen = true;
27
77
  let shutdownUntil;
@@ -44,6 +94,7 @@ export function createExtraService(options) {
44
94
  let acquired = false;
45
95
  let phase = "created";
46
96
  let client;
97
+ let scope;
47
98
  let logs;
48
99
  let plugins;
49
100
  let starting;
@@ -61,11 +112,11 @@ export function createExtraService(options) {
61
112
  const kernelAvailable = () => {
62
113
  if (healthCheck)
63
114
  return healthCheck;
64
- healthCheck = (client?.status().then((value) => value.execution_ready, () => false) ?? Promise.resolve(false))
115
+ healthCheck = (scope?.available() ?? Promise.resolve(false))
65
116
  .then((available) => {
66
117
  if (!owner.signal.aborted && available !== lastAvailable) {
67
118
  lastAvailable = available;
68
- logState(available ? "kernel.available" : "kernel.unavailable", available ? "available" : "unavailable");
119
+ logState(`${execution.kind === "ipc" ? "kernel" : "execution"}.${available ? "available" : "unavailable"}`, available ? "available" : "unavailable");
69
120
  }
70
121
  return available;
71
122
  })
@@ -92,7 +143,8 @@ export function createExtraService(options) {
92
143
  phase,
93
144
  name,
94
145
  pid: process.pid,
95
- kernel_available: await kernelAvailable(),
146
+ execution: { kind: execution.kind, available: await kernelAvailable() },
147
+ ...(execution.kind === "ipc" ? { kernel_available: await kernelAvailable() } : {}),
96
148
  plugin: !enabled
97
149
  ? { phase: "disabled" }
98
150
  : phase === "ready" && plugins
@@ -100,9 +152,9 @@ export function createExtraService(options) {
100
152
  : { phase }
101
153
  });
102
154
  const drainRuns = async () => {
103
- if (!client)
155
+ if (!scope)
104
156
  return;
105
- const result = await client.invocations.drain({
157
+ const result = await scope.drain({
106
158
  deadline: (cleanupDeadline ??= Date.now() + 5000),
107
159
  reason: "extra_shutdown"
108
160
  });
@@ -112,7 +164,7 @@ export function createExtraService(options) {
112
164
  const beginDrain = (signal) => {
113
165
  shutdownUntil ??= shutdownDeadline(signal);
114
166
  cleanupDeadline ??= Date.now() + Math.max(0, Math.floor(shutdownUntil - performance.now()));
115
- client?.invocations.stopAdmission();
167
+ scope?.stopAdmission();
116
168
  // 回滚通知先于加载器等待 disposer;立即取消源调用,避免消费者与清理互相等待。
117
169
  if (!draining) {
118
170
  draining = drainRuns();
@@ -169,7 +221,7 @@ export function createExtraService(options) {
169
221
  server.close((error) => (error ? reject(error) : resolve()));
170
222
  });
171
223
  });
172
- client?.close();
224
+ await attempt("execution", () => scope?.release());
173
225
  if (!errors.length)
174
226
  await attempt("control-endpoint", async () => {
175
227
  if (!release)
@@ -183,8 +235,10 @@ export function createExtraService(options) {
183
235
  if (acquired) {
184
236
  if (errors.length)
185
237
  ownership.failed = true;
186
- else
187
- owners.delete(key);
238
+ else {
239
+ ownerships.delete(key);
240
+ ownerCount--;
241
+ }
188
242
  }
189
243
  phase = errors.length ? "failed" : "closed";
190
244
  const result = {
@@ -223,21 +277,59 @@ export function createExtraService(options) {
223
277
  signal?.addEventListener("abort", abort, { once: true });
224
278
  if (signal?.aborted)
225
279
  abort();
280
+ let startupContext = { resource: "extra", operation: "initialize" };
226
281
  starting = (async () => {
227
282
  owner.signal.throwIfAborted();
228
- const previous = owners.get(key);
283
+ const paths = [
284
+ ...(controlEndpoint && process.platform !== "win32"
285
+ ? [{ path: `${controlEndpoint}.owner.recovery`, resource: "endpoint-ownership" }]
286
+ : []),
287
+ ...(logging
288
+ ? [
289
+ {
290
+ path: resolve(logging.directory, "extras", `${name}-status-20000101T00.log.lock`),
291
+ resource: "extra-log",
292
+ optional: true
293
+ }
294
+ ]
295
+ : [])
296
+ ];
297
+ if (execution.kind === "ipc" || home !== undefined)
298
+ validateRuntimeHome(home, paths);
299
+ else {
300
+ // 没有隐式 Home;控制目录必须已由宿主准备,日志继续沿可选 best-effort 合同。
301
+ if (controlEndpoint && process.platform !== "win32")
302
+ validateRuntimeHome(dirname(controlEndpoint), paths);
303
+ else
304
+ for (const path of paths)
305
+ assertRuntimePath(path.path, path.resource);
306
+ }
307
+ if (endpoint !== undefined)
308
+ assertIpcEndpoint(endpoint);
309
+ if (controlEndpoint)
310
+ assertIpcEndpoint(controlEndpoint);
311
+ const previous = ownerships.get(key);
229
312
  if (previous)
230
313
  throw new Error(previous.failed ? "EXTRA_DISPOSE_FAILED" : "EXTRA_ALREADY_LOADED");
231
- if (owners.size >= 64)
314
+ if (ownerCount >= 64)
232
315
  throw new Error("EXTRA_CAPACITY_EXHAUSTED");
233
- owners.set(key, ownership);
316
+ ownerships.set(key, ownership);
317
+ ownerCount++;
234
318
  acquired = true;
235
- client = attachKernel({ endpoint });
319
+ if (execution.kind === "ipc") {
320
+ client = attachKernel({ endpoint: execution.endpoint });
321
+ scope = createIpcExecutionScope(client);
322
+ }
323
+ else {
324
+ if (!execution.executor.status().available)
325
+ throw new Error("EXECUTOR_CLOSED");
326
+ scope = createDirectExecutionScope(execution.executor);
327
+ }
236
328
  logs = new RuntimeLogging(logging);
237
329
  logState("service.initializing", phase);
238
330
  if (logging)
239
331
  watchKernel();
240
- plugins = new ExtraPlugins([], client, () => logs.extra(name));
332
+ plugins = new ExtraPlugins([], { execution: scope.context, ...(client ? { kernel: client } : {}) }, () => logs.extra(name));
241
333
  if (enabled)
242
334
  await plugins.load({
243
335
  ...module,
@@ -251,8 +343,13 @@ export function createExtraService(options) {
251
343
  }, config, dependencies);
252
344
  owner.signal.throwIfAborted();
253
345
  if (controlEndpoint) {
254
- if (process.platform !== "win32")
255
- await mkdir(dirname(controlEndpoint), { recursive: true, mode: 0o700 });
346
+ startupContext = {
347
+ resource: "extra-control",
348
+ endpoint: controlEndpoint,
349
+ operation: "listen"
350
+ };
351
+ if (process.platform !== "win32" && home !== undefined)
352
+ prepareHomeDirectory(home, dirname(controlEndpoint));
256
353
  owner.signal.throwIfAborted();
257
354
  release = await acquireEndpoint(controlEndpoint);
258
355
  owner.signal.throwIfAborted();
@@ -275,7 +372,7 @@ export function createExtraService(options) {
275
372
  const request = JSON.parse(line);
276
373
  if (request.method !== "status")
277
374
  throw new Error("METHOD_NOT_FOUND");
278
- void status().then((value) => socket.end(`${JSON.stringify({ jsonrpc: "2.0", id: request.id, result: { name, pid: process.pid, status: { ...value.plugin, kernel_available: value.kernel_available } } })}\n`), () => socket.destroy());
375
+ void status().then((value) => socket.end(`${JSON.stringify({ jsonrpc: "2.0", id: request.id, result: { name, pid: process.pid, status: { ...value.plugin, execution: value.execution, ...(value.kernel_available === undefined ? {} : { kernel_available: value.kernel_available }) } } })}\n`), () => socket.destroy());
279
376
  }
280
377
  catch {
281
378
  socket.destroy();
@@ -296,8 +393,19 @@ export function createExtraService(options) {
296
393
  })();
297
394
  initialized = Promise.race([starting, cancelled])
298
395
  .catch(async (error) => {
396
+ const io = error;
397
+ if (startupContext.resource === "extra-control" &&
398
+ ["ENOENT", "ENOTDIR", "EACCES", "EPERM", "EROFS", "ENAMETOOLONG"].includes(io?.code ?? ""))
399
+ error = runtimePathFailure(error, typeof io.path === "string" ? io.path : (controlEndpoint ?? home ?? ""), "extra-control", typeof io.syscall === "string" ? io.syscall : "listen");
299
400
  logState("service.failed", "failed", "SERVICE_INITIALIZATION_FAILED");
300
- throw new ServiceInitializationError(error, await close());
401
+ throw new ServiceInitializationError(error, await close(), {
402
+ component: name,
403
+ phase: "initializing",
404
+ context: {
405
+ endpoint: controlEndpoint ?? endpoint,
406
+ ...startupContext
407
+ }
408
+ });
301
409
  })
302
410
  .finally(() => {
303
411
  signal?.removeEventListener("abort", abort);
@@ -1,5 +1,7 @@
1
1
  import type { KernelClient } from "@mininglamp-oss/octo-runtime-executor-kernel";
2
2
  import { type RuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
3
+ import { type ExtraExecutionContext } from "./execution.js";
4
+ export type { ExtraExecution, ExtraExecutionContext } from "./execution.js";
3
5
  export type { ChannelDependencies, LoadContexts } from "./context-loader.js";
4
6
  export type { RuntimeLog, RuntimeLogLevel } from "@mininglamp-oss/octo-runtime-adapter-sdk";
5
7
  export type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject;
@@ -12,7 +14,9 @@ export type ExtraStatusHandler = () => JsonObject;
12
14
  export interface ExtraContext {
13
15
  /** F31:.octospec/tasks/gateway-august-feature-assessment/assessment.md;无日志宿主也提供 no-op。 */
14
16
  readonly log: RuntimeLog;
15
- readonly kernel: KernelClient;
17
+ readonly execution: ExtraExecutionContext;
18
+ /** 仅 IPC 装配提供真实 client;旧插件使用前必须检查存在性。 */
19
+ readonly kernel?: KernelClient;
16
20
  readonly signal: AbortSignal;
17
21
  onDispose(dispose: ExtraDisposer): void;
18
22
  onStatus(handler: ExtraStatusHandler): void;
@@ -40,10 +44,13 @@ export declare function assertExtraName(name: unknown): asserts name is string;
40
44
  /** 每个声明名最多一个实例;只加载宿主选定的插件,并统一管理取消、状态和清理。 */
41
45
  export declare class ExtraPlugins {
42
46
  #private;
43
- private readonly kernel;
47
+ private readonly binding;
44
48
  private readonly logForExtra;
45
49
  static validate(registrations: readonly ExtraRegistration[]): void;
46
- constructor(registrations: readonly ExtraRegistration[], kernel: KernelClient, logForExtra?: (name: string) => RuntimeLog);
50
+ constructor(registrations: readonly ExtraRegistration[], binding: KernelClient | {
51
+ execution: ExtraExecutionContext;
52
+ kernel?: KernelClient;
53
+ }, logForExtra?: (name: string) => RuntimeLog);
47
54
  get status(): Record<string, ExtraStatus>;
48
55
  loadConfigured(): Promise<void>;
49
56
  inspect(name: string): Promise<JsonObject>;