@mininglamp-oss/octo-runtime-client 0.0.0-stage → 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.
- package/LICENSE +190 -0
- package/README.md +38 -2
- package/build-info.json +5 -0
- package/dist/async-question-reply.d.ts +30 -0
- package/dist/async-question-reply.js +199 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.js +465 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +5 -0
- package/dist/invocation-lifecycle.d.ts +59 -0
- package/dist/invocation-lifecycle.js +287 -0
- package/dist/notification.d.ts +1 -0
- package/dist/notification.js +1 -0
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.js +1 -0
- package/dist/runtime-path.d.ts +21 -0
- package/dist/runtime-path.js +138 -0
- package/dist/startup-catalog.d.ts +8 -0
- package/dist/startup-catalog.js +65 -0
- package/dist/startup-diagnostics.d.ts +82 -0
- package/dist/startup-diagnostics.js +371 -0
- package/dist/submission-error.d.ts +10 -0
- package/dist/submission-error.js +23 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +11 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +33 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +58 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-hash.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-hash.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +29 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +566 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +80 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +166 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +82 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +562 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +3022 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +124 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +709 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +129 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +177 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-size.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-size.js +11 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/json-size.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/json-size.js +91 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +166 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/notification.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/notification.js +137 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +294 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +68 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/stream-limits.d.ts +27 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/stream-limits.js +56 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +15 -0
- package/package.json +55 -4
- package/schema/context-configuration-fixtures.json +1219 -0
- package/schema/context-fixtures.json +5988 -0
- package/schema/kernel-client.behavior.json +56 -0
- package/schema/kernel-ipc-fixtures.json +53 -0
- package/schema/kernel-ipc.schema.json +538 -0
- package/schema/native-invoke-fixtures.json +116 -0
- package/schema/protocol.schema.json +4525 -0
- package/schema/run-protocol-fixtures.json +761 -0
- package/schema/runtime-selection-fixtures.json +663 -0
- package/schema/session-name-fixtures.json +191 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const record = (value) => {
|
|
2
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3
|
+
throw new TypeError("INVALID_KERNEL_STATUS");
|
|
4
|
+
return value;
|
|
5
|
+
};
|
|
6
|
+
const positive = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
7
|
+
/** status 的安全进程白名单与共享 Schema 对齐,拒绝任意 argv/env 扩展字段。 */
|
|
8
|
+
export function assertServiceProcessSnapshot(value) {
|
|
9
|
+
const item = record(value);
|
|
10
|
+
if (Object.keys(item).some((key) => ![
|
|
11
|
+
"scope_id",
|
|
12
|
+
"service_id",
|
|
13
|
+
"incarnation",
|
|
14
|
+
"provider",
|
|
15
|
+
"owner_pid",
|
|
16
|
+
"pid",
|
|
17
|
+
"state",
|
|
18
|
+
"observation",
|
|
19
|
+
"ownership"
|
|
20
|
+
].includes(key)) ||
|
|
21
|
+
["scope_id", "service_id", "provider"].some((key) => typeof item[key] !== "string" || !item[key].length) ||
|
|
22
|
+
typeof item.incarnation !== "number" ||
|
|
23
|
+
!Number.isSafeInteger(item.incarnation) ||
|
|
24
|
+
item.incarnation < 0 ||
|
|
25
|
+
!positive(item.owner_pid) ||
|
|
26
|
+
(item.pid !== undefined && !positive(item.pid)) ||
|
|
27
|
+
typeof item.state !== "string" ||
|
|
28
|
+
![
|
|
29
|
+
"not_started",
|
|
30
|
+
"starting",
|
|
31
|
+
"ready",
|
|
32
|
+
"recovering",
|
|
33
|
+
"degraded",
|
|
34
|
+
"closing",
|
|
35
|
+
"closed",
|
|
36
|
+
"cleanup_incomplete"
|
|
37
|
+
].includes(item.state) ||
|
|
38
|
+
typeof item.observation !== "string" ||
|
|
39
|
+
!["alive", "exited", "unknown"].includes(item.observation) ||
|
|
40
|
+
item.ownership !== "owned")
|
|
41
|
+
throw new TypeError("INVALID_KERNEL_STATUS");
|
|
42
|
+
}
|
|
43
|
+
/** 兼容没有服务快照的旧 status;有快照时完整校验后才能交给 doctor。 */
|
|
44
|
+
export function assertKernelStatus(value) {
|
|
45
|
+
const item = record(value);
|
|
46
|
+
if (Object.keys(item).some((key) => ![
|
|
47
|
+
"ipc_version",
|
|
48
|
+
"kernel_instance_id",
|
|
49
|
+
"pid",
|
|
50
|
+
"execution_ready",
|
|
51
|
+
"service_processes"
|
|
52
|
+
].includes(key)) ||
|
|
53
|
+
item.ipc_version !== 1 ||
|
|
54
|
+
typeof item.kernel_instance_id !== "string" ||
|
|
55
|
+
!item.kernel_instance_id ||
|
|
56
|
+
!positive(item.pid) ||
|
|
57
|
+
typeof item.execution_ready !== "boolean")
|
|
58
|
+
throw new TypeError("INVALID_KERNEL_STATUS");
|
|
59
|
+
if (item.service_processes !== undefined) {
|
|
60
|
+
if (!Array.isArray(item.service_processes) || item.service_processes.length > 256)
|
|
61
|
+
throw new TypeError("INVALID_KERNEL_STATUS");
|
|
62
|
+
for (const process of item.service_processes)
|
|
63
|
+
assertServiceProcessSnapshot(process);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface StreamLimitPolicy {
|
|
2
|
+
rawMessageMaxBytes: number;
|
|
3
|
+
adapterQueueItemMaxBytes: number;
|
|
4
|
+
adapterQueueMaxBytes: number;
|
|
5
|
+
adapterQueueMaxItems: number;
|
|
6
|
+
hostFrameMaxBytes: number;
|
|
7
|
+
rpcQueueMaxBytes: number;
|
|
8
|
+
rpcQueueMaxItems: number;
|
|
9
|
+
replayRunMaxBytes: number;
|
|
10
|
+
replayRunMaxItems: number;
|
|
11
|
+
replayGlobalMaxBytes: number;
|
|
12
|
+
}
|
|
13
|
+
export type StreamLimitOverrides = Partial<StreamLimitPolicy>;
|
|
14
|
+
export declare const DEFAULT_STREAM_LIMIT_POLICY: Readonly<StreamLimitPolicy>;
|
|
15
|
+
export declare const MAX_STREAM_LIMIT_POLICY: Readonly<StreamLimitPolicy>;
|
|
16
|
+
export declare const HOST_RPC_MAX_LINE_BYTES: number;
|
|
17
|
+
export declare function resolveStreamLimitPolicy(overrides: StreamLimitOverrides | undefined): Readonly<StreamLimitPolicy>;
|
|
18
|
+
export declare const STREAM_CAPACITY_REASONS: readonly ["PROVIDER_MESSAGE_TOO_LARGE", "HOST_FRAME_TOO_LARGE", "STREAM_QUEUE_ITEM_TOO_LARGE", "STREAM_QUEUE_BYTES_EXCEEDED", "STREAM_QUEUE_ITEMS_EXCEEDED"];
|
|
19
|
+
export type StreamCapacityReason = (typeof STREAM_CAPACITY_REASONS)[number];
|
|
20
|
+
export declare function isStreamCapacityReason(value: unknown): value is StreamCapacityReason;
|
|
21
|
+
export declare function streamCapacityError(code: StreamCapacityReason, detail: {
|
|
22
|
+
boundary: string;
|
|
23
|
+
measuredBytes?: number;
|
|
24
|
+
limitBytes?: number;
|
|
25
|
+
itemCount?: number;
|
|
26
|
+
limitItems?: number;
|
|
27
|
+
}): Error;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const MIB = 1024 * 1024;
|
|
2
|
+
export const DEFAULT_STREAM_LIMIT_POLICY = Object.freeze({
|
|
3
|
+
rawMessageMaxBytes: 16 * MIB,
|
|
4
|
+
adapterQueueItemMaxBytes: 20 * MIB,
|
|
5
|
+
adapterQueueMaxBytes: 32 * MIB,
|
|
6
|
+
adapterQueueMaxItems: 4096,
|
|
7
|
+
hostFrameMaxBytes: 20 * MIB,
|
|
8
|
+
rpcQueueMaxBytes: 32 * MIB,
|
|
9
|
+
rpcQueueMaxItems: 4096,
|
|
10
|
+
replayRunMaxBytes: 32 * MIB,
|
|
11
|
+
replayRunMaxItems: 4096,
|
|
12
|
+
replayGlobalMaxBytes: 128 * MIB
|
|
13
|
+
});
|
|
14
|
+
export const MAX_STREAM_LIMIT_POLICY = Object.freeze(Object.fromEntries(Object.entries(DEFAULT_STREAM_LIMIT_POLICY).map(([key, value]) => [key, value * 2])));
|
|
15
|
+
export const HOST_RPC_MAX_LINE_BYTES = MAX_STREAM_LIMIT_POLICY.hostFrameMaxBytes + 64 * 1024;
|
|
16
|
+
export function resolveStreamLimitPolicy(overrides) {
|
|
17
|
+
if (overrides !== undefined &&
|
|
18
|
+
(overrides === null || typeof overrides !== "object" || Array.isArray(overrides)))
|
|
19
|
+
throw new TypeError("stream_limits must be an object");
|
|
20
|
+
const fields = new Set(Object.keys(DEFAULT_STREAM_LIMIT_POLICY));
|
|
21
|
+
for (const key of Object.keys(overrides ?? {})) {
|
|
22
|
+
if (!fields.has(key))
|
|
23
|
+
throw new TypeError(`unknown stream_limits.${key}`);
|
|
24
|
+
}
|
|
25
|
+
const policy = { ...DEFAULT_STREAM_LIMIT_POLICY, ...(overrides ?? {}) };
|
|
26
|
+
for (const key of Object.keys(DEFAULT_STREAM_LIMIT_POLICY)) {
|
|
27
|
+
const value = policy[key];
|
|
28
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > MAX_STREAM_LIMIT_POLICY[key]) {
|
|
29
|
+
throw new TypeError(`invalid stream_limits.${key}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (policy.rawMessageMaxBytes > policy.adapterQueueItemMaxBytes)
|
|
33
|
+
throw new TypeError("stream_limits.rawMessageMaxBytes exceeds adapterQueueItemMaxBytes");
|
|
34
|
+
if (policy.adapterQueueItemMaxBytes > policy.adapterQueueMaxBytes)
|
|
35
|
+
throw new TypeError("stream_limits.adapterQueueItemMaxBytes exceeds adapterQueueMaxBytes");
|
|
36
|
+
if (policy.hostFrameMaxBytes > policy.rpcQueueMaxBytes)
|
|
37
|
+
throw new TypeError("stream_limits.hostFrameMaxBytes exceeds rpcQueueMaxBytes");
|
|
38
|
+
if (policy.hostFrameMaxBytes > policy.replayRunMaxBytes)
|
|
39
|
+
throw new TypeError("stream_limits.hostFrameMaxBytes exceeds replayRunMaxBytes");
|
|
40
|
+
if (policy.replayRunMaxBytes > policy.replayGlobalMaxBytes)
|
|
41
|
+
throw new TypeError("stream_limits.replayRunMaxBytes exceeds replayGlobalMaxBytes");
|
|
42
|
+
return Object.freeze(policy);
|
|
43
|
+
}
|
|
44
|
+
export const STREAM_CAPACITY_REASONS = [
|
|
45
|
+
"PROVIDER_MESSAGE_TOO_LARGE",
|
|
46
|
+
"HOST_FRAME_TOO_LARGE",
|
|
47
|
+
"STREAM_QUEUE_ITEM_TOO_LARGE",
|
|
48
|
+
"STREAM_QUEUE_BYTES_EXCEEDED",
|
|
49
|
+
"STREAM_QUEUE_ITEMS_EXCEEDED"
|
|
50
|
+
];
|
|
51
|
+
export function isStreamCapacityReason(value) {
|
|
52
|
+
return STREAM_CAPACITY_REASONS.includes(value);
|
|
53
|
+
}
|
|
54
|
+
export function streamCapacityError(code, detail) {
|
|
55
|
+
return Object.assign(new Error(code), { code, ...detail });
|
|
56
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mininglamp-oss/octo-runtime-protocol",
|
|
3
|
+
"version": "1.1.11",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./browser": "./dist/browser.js",
|
|
9
|
+
"./notification": "./dist/notification.js"
|
|
10
|
+
},
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-client",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "1.1.11",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Standalone Node.js client and shared protocol for an existing Octo Runtime Kernel",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./protocol": {
|
|
15
|
+
"types": "./dist/protocol.d.ts",
|
|
16
|
+
"import": "./dist/protocol.js"
|
|
17
|
+
},
|
|
18
|
+
"./protocol/browser": {
|
|
19
|
+
"types": "./dist/browser.d.ts",
|
|
20
|
+
"import": "./dist/browser.js"
|
|
21
|
+
},
|
|
22
|
+
"./protocol/notification": {
|
|
23
|
+
"types": "./dist/notification.d.ts",
|
|
24
|
+
"import": "./dist/notification.js"
|
|
25
|
+
},
|
|
26
|
+
"./protocol/schema.json": "./schema/protocol.schema.json",
|
|
27
|
+
"./protocol/ipc-schema.json": "./schema/kernel-ipc.schema.json",
|
|
28
|
+
"./protocol/ipc-fixtures.json": "./schema/kernel-ipc-fixtures.json",
|
|
29
|
+
"./protocol/behavior.json": "./schema/kernel-client.behavior.json",
|
|
30
|
+
"./internal": {
|
|
31
|
+
"types": "./dist/internal.d.ts",
|
|
32
|
+
"import": "./dist/internal.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"schema",
|
|
38
|
+
"build-info.json"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": "^24.0.0 || ^26.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/Mininglamp-OSS/octo-runtime.git",
|
|
49
|
+
"directory": "packages/octo-runtime-client"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.11"
|
|
53
|
+
},
|
|
54
|
+
"bundleDependencies": [
|
|
55
|
+
"@mininglamp-oss/octo-runtime-protocol"
|
|
56
|
+
]
|
|
57
|
+
}
|