@saturn-universe/runtime-host 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +661 -0
  2. package/dist/builtin-plugins/saturn-plugin-ctf/README.md +13 -0
  3. package/dist/builtin-plugins/saturn-plugin-ctf/index.mjs +1473 -0
  4. package/dist/builtin-plugins/saturn-plugin-ctf/package.json +10 -0
  5. package/dist/builtin-plugins/saturn-plugin-ctf/src/board.mjs +321 -0
  6. package/dist/builtin-plugins/saturn-plugin-ctf/src/ledger.mjs +1143 -0
  7. package/dist/builtin-plugins/saturn-plugin-ctf/src/platform/ctfd.mjs +154 -0
  8. package/dist/builtin-plugins/saturn-plugin-ctf/src/platform/ctfplus.mjs +769 -0
  9. package/dist/builtin-plugins/saturn-plugin-ctf/src/platform/gzctf.mjs +130 -0
  10. package/dist/builtin-plugins/saturn-plugin-ctf/src/platform/http.mjs +336 -0
  11. package/dist/builtin-plugins/saturn-plugin-ctf/src/platform/index.mjs +133 -0
  12. package/dist/builtin-plugins/saturn-plugin-ctf/src/platform/lease.mjs +153 -0
  13. package/dist/builtin-plugins/saturn-plugin-ctf/src/server.mjs +336 -0
  14. package/dist/builtin-plugins/saturn-plugin-ctf/src/view.mjs +714 -0
  15. package/dist/command-dispatch.d.ts +10 -0
  16. package/dist/command-dispatch.js +65 -0
  17. package/dist/completion-judge.d.ts +10 -0
  18. package/dist/completion-judge.js +156 -0
  19. package/dist/composition.d.ts +108 -0
  20. package/dist/composition.js +1180 -0
  21. package/dist/configuration.d.ts +49 -0
  22. package/dist/configuration.js +51 -0
  23. package/dist/context-extensions.d.ts +681 -0
  24. package/dist/context-extensions.js +289 -0
  25. package/dist/cordis/context-core-plugin.d.ts +35 -0
  26. package/dist/cordis/context-core-plugin.js +296 -0
  27. package/dist/cordis/env-probe-plugin.d.ts +27 -0
  28. package/dist/cordis/env-probe-plugin.js +114 -0
  29. package/dist/cordis/host-context.d.ts +65 -0
  30. package/dist/cordis/host-context.js +199 -0
  31. package/dist/cordis/model-responses-plugin.d.ts +81 -0
  32. package/dist/cordis/model-responses-plugin.js +209 -0
  33. package/dist/cordis/plugin-contributions.d.ts +47 -0
  34. package/dist/cordis/plugin-contributions.js +119 -0
  35. package/dist/cordis/plugin-lifecycle.d.ts +57 -0
  36. package/dist/cordis/plugin-lifecycle.js +222 -0
  37. package/dist/cordis/plugin-loader.d.ts +18 -0
  38. package/dist/cordis/plugin-loader.js +310 -0
  39. package/dist/cordis/plugin-sdk-adapter.d.ts +17 -0
  40. package/dist/cordis/plugin-sdk-adapter.js +283 -0
  41. package/dist/cordis/required-host-plugin.d.ts +6 -0
  42. package/dist/cordis/required-host-plugin.js +1 -0
  43. package/dist/cordis/runtime-hooks-plugin.d.ts +23 -0
  44. package/dist/cordis/runtime-hooks-plugin.js +103 -0
  45. package/dist/cordis/sandbox-plugin.d.ts +18 -0
  46. package/dist/cordis/sandbox-plugin.js +21 -0
  47. package/dist/cordis/scoped-layers.d.ts +63 -0
  48. package/dist/cordis/scoped-layers.js +170 -0
  49. package/dist/cordis/tools/builtin-agent-tools-plugin.d.ts +11 -0
  50. package/dist/cordis/tools/builtin-agent-tools-plugin.js +171 -0
  51. package/dist/cordis/tools/index.d.ts +17 -0
  52. package/dist/cordis/tools/index.js +40 -0
  53. package/dist/cordis/tools/mcp-tools-plugin.d.ts +7 -0
  54. package/dist/cordis/tools/mcp-tools-plugin.js +116 -0
  55. package/dist/cordis/tools/process-manager-plugin.d.ts +11 -0
  56. package/dist/cordis/tools/process-manager-plugin.js +39 -0
  57. package/dist/cordis/tools/sandbox-target-tools-plugin.d.ts +13 -0
  58. package/dist/cordis/tools/sandbox-target-tools-plugin.js +255 -0
  59. package/dist/cordis/tools/tool-guidance.d.ts +4 -0
  60. package/dist/cordis/tools/tool-guidance.js +30 -0
  61. package/dist/cordis/tools/tools-core-plugin.d.ts +128 -0
  62. package/dist/cordis/tools/tools-core-plugin.js +486 -0
  63. package/dist/cordis/tools/web-fetch.d.ts +17 -0
  64. package/dist/cordis/tools/web-fetch.js +529 -0
  65. package/dist/cordis/tools/web-search-tools-plugin.d.ts +10 -0
  66. package/dist/cordis/tools/web-search-tools-plugin.js +191 -0
  67. package/dist/cordis/tools/workspace-tools-plugin.d.ts +8 -0
  68. package/dist/cordis/tools/workspace-tools-plugin.js +145 -0
  69. package/dist/env-probe.d.ts +8 -0
  70. package/dist/env-probe.js +172 -0
  71. package/dist/host-configuration.d.ts +27 -0
  72. package/dist/host-configuration.js +185 -0
  73. package/dist/host-tools.d.ts +19 -0
  74. package/dist/host-tools.js +30 -0
  75. package/dist/index.d.ts +2 -0
  76. package/dist/index.js +140 -0
  77. package/dist/ipc.d.ts +24 -0
  78. package/dist/ipc.js +162 -0
  79. package/dist/logger.d.ts +11 -0
  80. package/dist/logger.js +84 -0
  81. package/dist/mcp-configuration.d.ts +17 -0
  82. package/dist/mcp-configuration.js +50 -0
  83. package/dist/modes.d.ts +27 -0
  84. package/dist/modes.js +472 -0
  85. package/dist/ownership.d.ts +7 -0
  86. package/dist/ownership.js +100 -0
  87. package/dist/plugin-configuration.d.ts +9 -0
  88. package/dist/plugin-configuration.js +21 -0
  89. package/dist/plugin-tool-grants.d.ts +18 -0
  90. package/dist/plugin-tool-grants.js +21 -0
  91. package/dist/process-workspaces.d.ts +4 -0
  92. package/dist/process-workspaces.js +28 -0
  93. package/dist/progress.d.ts +30 -0
  94. package/dist/progress.js +699 -0
  95. package/dist/provider-catalog.d.ts +754 -0
  96. package/dist/provider-catalog.js +471 -0
  97. package/dist/run-budget.d.ts +24 -0
  98. package/dist/run-budget.js +47 -0
  99. package/dist/run-checkpoint.d.ts +2 -0
  100. package/dist/run-checkpoint.js +52 -0
  101. package/dist/sandbox-manager.d.ts +111 -0
  102. package/dist/sandbox-manager.js +1519 -0
  103. package/dist/session-paths.d.ts +15 -0
  104. package/dist/session-paths.js +40 -0
  105. package/dist/side-question.d.ts +14 -0
  106. package/dist/side-question.js +89 -0
  107. package/dist/skills-runtime.d.ts +13 -0
  108. package/dist/skills-runtime.js +243 -0
  109. package/dist/token-estimator.d.ts +3 -0
  110. package/dist/token-estimator.js +73 -0
  111. package/dist/tool-result.d.ts +2 -0
  112. package/dist/tool-result.js +91 -0
  113. package/dist/user-config.d.ts +23 -0
  114. package/dist/user-config.js +36 -0
  115. package/package.json +28 -3
  116. package/README.md +0 -3
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export declare function configurationTable<T extends z.ZodType>(key: z.ZodType<string>, value: T): z.ZodPreprocess<z.ZodPipe<z.ZodArray<z.ZodTuple<[z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, T], null>>, z.ZodTransform<Record<string, z.output<T>>, [...T["_zod"]["optout"] extends "optional" ? [string, z.core.output<T>?] : [string, z.core.output<T>]][]>>, unknown>;
3
+ type PluginConfigValue = string | number | boolean | PluginConfigValue[] | {
4
+ [key: string]: PluginConfigValue;
5
+ };
6
+ export declare const pluginConfigSchema: z.ZodPreprocess<z.ZodPipe<z.ZodArray<z.ZodTuple<[z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodType<PluginConfigValue, unknown, z.core.$ZodTypeInternals<PluginConfigValue, unknown>>], null>>, z.ZodTransform<Record<string, PluginConfigValue>, [string, PluginConfigValue][]>>, unknown>;
7
+ export declare const pluginIdSchema: z.ZodString;
8
+ export declare const pluginEntrySchema: z.ZodString;
9
+ export {};
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export function configurationTable(key, value) {
3
+ // Parse own entries so a TOML key such as __proto__ is preserved as data.
4
+ return z.preprocess((input) => {
5
+ if (input && typeof input === 'object') {
6
+ const prototype = Object.getPrototypeOf(input);
7
+ if (prototype === null || prototype === Object.prototype)
8
+ return Object.entries(input);
9
+ }
10
+ }, z
11
+ .array(z.tuple([key, value]))
12
+ .transform((entries) => Object.fromEntries(entries)));
13
+ }
14
+ const pluginConfigValue = z.lazy(() => z.union([z.string(), z.number(), z.boolean(), z.array(pluginConfigValue), pluginConfigSchema]));
15
+ export const pluginConfigSchema = configurationTable(z.string(), pluginConfigValue);
16
+ export const pluginIdSchema = z
17
+ .string()
18
+ .min(1)
19
+ .max(200)
20
+ .refine((value) => value === value.trim());
21
+ export const pluginEntrySchema = z.string().refine((value) => Boolean(value.trim()) && !value.includes('\0'));
@@ -0,0 +1,18 @@
1
+ import type { ModePluginToolsGrant } from '@saturn-universe/core';
2
+ import { z } from 'zod';
3
+ export type PluginToolGrants = Readonly<Record<string, ModePluginToolsGrant>>;
4
+ interface ConfiguredPluginToolGrant {
5
+ readonly allowed_tools?: readonly string[] | undefined;
6
+ readonly read_only_tools?: readonly string[] | undefined;
7
+ readonly auto_approve_tools?: readonly string[] | undefined;
8
+ }
9
+ export declare function configuredPluginGrantFields(toolNames: z.ZodType<string[]>): {
10
+ allowed_tools: z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>;
11
+ read_only_tools: z.ZodOptional<z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>>;
12
+ auto_approve_tools: z.ZodOptional<z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>>;
13
+ };
14
+ export declare function validConfiguredPluginGrant(grant: ConfiguredPluginToolGrant): boolean;
15
+ export declare function readConfiguredPluginGrant(grant: ConfiguredPluginToolGrant & {
16
+ readonly allowed_tools: readonly string[];
17
+ }): ModePluginToolsGrant;
18
+ export {};
@@ -0,0 +1,21 @@
1
+ export function configuredPluginGrantFields(toolNames) {
2
+ return {
3
+ allowed_tools: toolNames,
4
+ read_only_tools: toolNames.optional(),
5
+ auto_approve_tools: toolNames.optional(),
6
+ };
7
+ }
8
+ export function validConfiguredPluginGrant(grant) {
9
+ const { allowed_tools, read_only_tools, auto_approve_tools } = grant;
10
+ if (!allowed_tools)
11
+ return read_only_tools === undefined && auto_approve_tools === undefined;
12
+ return ((read_only_tools?.every((name) => allowed_tools.includes(name)) ?? true) &&
13
+ (auto_approve_tools?.every((name) => allowed_tools.includes(name)) ?? true));
14
+ }
15
+ export function readConfiguredPluginGrant(grant) {
16
+ return {
17
+ allowedTools: [...grant.allowed_tools],
18
+ ...(grant.read_only_tools ? { readOnlyTools: [...grant.read_only_tools] } : {}),
19
+ ...(grant.auto_approve_tools ? { autoApproveTools: [...grant.auto_approve_tools] } : {}),
20
+ };
21
+ }
@@ -0,0 +1,4 @@
1
+ import type { WorkspaceSnapshotPort } from '@saturn-universe/core';
2
+ import type { ProcessManager } from '@saturn-universe/tools';
3
+ /** Freeze process writers before observing or removing an isolated branch. */
4
+ export declare function withProcessWorkspaceCleanup(workspace: WorkspaceSnapshotPort, processes: Pick<ProcessManager, 'stopWorkspace'> | undefined, reportUnconfirmed: (processId: string) => void): WorkspaceSnapshotPort;
@@ -0,0 +1,28 @@
1
+ import { RuntimeError } from '@saturn-universe/core';
2
+ import { isManagedBranchWorkspace } from '@saturn-universe/tools';
3
+ /** Freeze process writers before observing or removing an isolated branch. */
4
+ export function withProcessWorkspaceCleanup(workspace, processes, reportUnconfirmed) {
5
+ async function stop(handle, root) {
6
+ if (!processes ||
7
+ handle.kind === 'shared_readonly' ||
8
+ !isManagedBranchWorkspace(root, handle.workingDirectory))
9
+ return;
10
+ const results = await processes.stopWorkspace(handle.workingDirectory, true);
11
+ for (const result of results)
12
+ if (!result.terminationConfirmed)
13
+ reportUnconfirmed(result.processId);
14
+ if (results.some(({ status }) => status !== 'exited'))
15
+ throw new RuntimeError('PROCESS_CLEANUP_UNCONFIRMED', 'Isolated workspace was retained because a process could not be stopped');
16
+ }
17
+ return {
18
+ createBranchWorkspace: (input) => workspace.createBranchWorkspace(input),
19
+ async mergeBranchWorkspace(handle, root) {
20
+ await stop(handle, root);
21
+ return workspace.mergeBranchWorkspace(handle, root);
22
+ },
23
+ async cleanupBranchWorkspace(handle, root) {
24
+ await stop(handle, root);
25
+ await workspace.cleanupBranchWorkspace(handle, root);
26
+ },
27
+ };
28
+ }
@@ -0,0 +1,30 @@
1
+ import type { AgentContextMetrics, AgentInput, AgentSessionId, HostCommand, JsonValue, LiveAgentTelemetry, RequestId, RunId, TurnId } from '@saturn-universe/core';
2
+ import type { LiveAgentUpdate } from '@saturn-universe/runtime';
3
+ import type { SqliteStore } from '@saturn-universe/storage';
4
+ export declare function createLiveText(): {
5
+ update(input: AgentInput, { reasoningDelta, resetReasoning, ...patch }: LiveAgentUpdate): void;
6
+ clearAgent({ runId, agentSessionId, turnId }: AgentInput): void;
7
+ agentSnapshots(runId: RunId): never[] | MapIterator<[AgentSessionId, {
8
+ turnId: TurnId;
9
+ snapshot: Omit<LiveAgentTelemetry, "memberId">;
10
+ }]>;
11
+ runMetrics(runId: RunId): never[] | MapIterator<[AgentSessionId, AgentContextMetrics]>;
12
+ sessionMetrics(agentSessionId: AgentSessionId): AgentContextMetrics | undefined;
13
+ append(input: AgentInput, delta: {
14
+ requestId: RequestId;
15
+ index: number;
16
+ text: string;
17
+ }): void;
18
+ clear(requestId: RequestId): void;
19
+ mainDraft(runId: RunId, members: ReadonlyMap<string, string>): {
20
+ requestId: RequestId;
21
+ revision: number;
22
+ text: string;
23
+ } | undefined;
24
+ };
25
+ export declare function runProgress(store: SqliteStore, command: Extract<HostCommand, {
26
+ type: 'run.progress';
27
+ }>, liveText?: ReturnType<typeof createLiveText>): Promise<JsonValue>;
28
+ export declare function runTimeline(store: SqliteStore, { runId, after }: Extract<HostCommand, {
29
+ type: 'run.timeline';
30
+ }>): Promise<JsonValue>;