@themoltnet/pi-runtime 0.3.0 → 0.5.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 (3) hide show
  1. package/dist/index.d.ts +57 -20
  2. package/dist/index.js +514 -526
  3. package/package.json +7 -7
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ import { GrepToolInput } from '@earendil-works/pi-coding-agent';
14
14
  import { LoadSkillsResult } from '@earendil-works/pi-coding-agent';
15
15
  import { LsOperations } from '@earendil-works/pi-coding-agent';
16
16
  import { Model } from '@earendil-works/pi-ai';
17
+ import { ModelRegistry } from '@earendil-works/pi-coding-agent';
17
18
  import { Readable } from 'node:stream';
18
19
  import { ReadOperations } from '@earendil-works/pi-coding-agent';
19
20
  import { ShellCommandAnalyzer } from '@themoltnet/shell-command-analyzer';
@@ -46,6 +47,7 @@ export declare interface AllowedToolsClient {
46
47
  allowedShellCommands: Array<{
47
48
  argvPrefix: string[];
48
49
  }>;
50
+ runtimeKind: string;
49
51
  }>;
50
52
  };
51
53
  }
@@ -68,6 +70,8 @@ declare interface BuildAgentSessionArgs {
68
70
  piAuthDir: string;
69
71
  /** Resolved pi model handle (provider + model id). */
70
72
  modelHandle: Model<Api>;
73
+ /** Registry that resolved modelHandle, including custom providers/auth. */
74
+ modelRegistry?: ModelRegistry;
71
75
  /** Optional runtime-profile thinking/reasoning level applied at session start. */
72
76
  thinkingLevel?: PiThinkingLevel | null;
73
77
  /** Optional runtime-profile sampling temperature applied to provider requests. */
@@ -188,6 +192,8 @@ export declare interface CreateSubagentToolArgs {
188
192
  piAuthDir: string;
189
193
  /** Resolved pi model handle — subagents share it. */
190
194
  modelHandle: Model<Api>;
195
+ /** Registry that resolved modelHandle — subagents share it. */
196
+ modelRegistry?: ModelRegistry;
191
197
  /** Runtime-profile thinking/reasoning level — subagents inherit it. */
192
198
  thinkingLevel?: PiThinkingLevel | null;
193
199
  /** Runtime-profile sampling temperature — subagents inherit it. */
@@ -348,10 +354,7 @@ export declare function definePiTool(options: PiToolFactoryOptions): PiToolContr
348
354
  export declare function enabledPiToolNames(input: {
349
355
  tools: readonly ToolDefinition[];
350
356
  extensions?: readonly PiExtensionContribution[];
351
- policy?: {
352
- enforcement: ToolEnforcement;
353
- allowedTools: ReadonlySet<string>;
354
- };
357
+ policy?: ModelVisibleToolPolicy;
355
358
  }): string[] | undefined;
356
359
 
357
360
  /**
@@ -575,10 +578,7 @@ export declare interface ExecutePiTaskOptions {
575
578
  resolveVmTemplate?: () => Promise<ResolvedGondolinTemplate>;
576
579
  }
577
580
 
578
- export declare function filterModelVisibleTools(tools: readonly ToolDefinition[], policy?: {
579
- enforcement: ToolEnforcement;
580
- allowedTools: ReadonlySet<string>;
581
- }): ToolDefinition[];
581
+ export declare function filterModelVisibleTools(tools: readonly ToolDefinition[], policy?: ModelVisibleToolPolicy): ToolDefinition[];
582
582
 
583
583
  /**
584
584
  * Resolve the main worktree root (where .moltnet/ lives — it's untracked,
@@ -688,10 +688,17 @@ export declare interface InjectTaskContextArgs {
688
688
 
689
689
  export declare function isKernelTool(name: string): boolean;
690
690
 
691
- export declare function isToolVisible(name: string, policy?: {
692
- enforcement: ToolEnforcement;
693
- allowedTools: ReadonlySet<string>;
694
- }): boolean;
691
+ /**
692
+ * Check containment for already-resolved lexical or real paths.
693
+ *
694
+ * Callers that accept untrusted paths must resolve/realpath at their I/O
695
+ * boundary first; keeping the platform-specific relative-path rule here avoids
696
+ * subtly different `..` and absolute-path handling across runtime cleanup,
697
+ * session sync, and artifact staging.
698
+ */
699
+ export declare function isResolvedPathInsideRoot(path: string, root: string): boolean;
700
+
701
+ export declare function isToolVisible(name: string, policy?: ModelVisibleToolPolicy): boolean;
695
702
 
696
703
  export declare function loadCredentials(agentDir: string): VmCredentials;
697
704
 
@@ -713,20 +720,14 @@ export declare function materializePiExtensions(input: {
713
720
  runtime: PiRuntimeDefinition;
714
721
  context: PiToolContext;
715
722
  target: 'parent' | 'subagent';
716
- policy?: {
717
- enforcement: ToolEnforcement;
718
- allowedTools: ReadonlySet<string>;
719
- };
723
+ policy?: ModelVisibleToolPolicy;
720
724
  }): Promise<PiExtensionFactory[]>;
721
725
 
722
726
  export declare function materializePiTools(input: {
723
727
  runtime: PiRuntimeDefinition;
724
728
  context: PiToolContext;
725
729
  target: 'parent' | 'subagent';
726
- policy?: {
727
- enforcement: ToolEnforcement;
728
- allowedTools: ReadonlySet<string>;
729
- };
730
+ policy?: ModelVisibleToolPolicy;
730
731
  }): Promise<ToolDefinition[]>;
731
732
 
732
733
  /**
@@ -741,6 +742,14 @@ declare interface MissingShellCommand {
741
742
  dynamicTokenCount: number;
742
743
  }
743
744
 
745
+ export declare interface ModelVisibleToolPolicy {
746
+ enforcement: ToolEnforcement;
747
+ allowedTools: ReadonlySet<string>;
748
+ allowedShellCommands?: readonly {
749
+ argvPrefix: readonly string[];
750
+ }[];
751
+ }
752
+
744
753
  export declare const MOLTNET_TOOL_NAMES: readonly ["moltnet_pack_get", "moltnet_pack_create", "moltnet_pack_provenance", "moltnet_pack_render", "moltnet_rendered_pack_list", "moltnet_rendered_pack_get", "moltnet_diary_tags", "moltnet_list_entries", "moltnet_get_entry", "moltnet_search_entries", "moltnet_create_entry", "moltnet_get_task", "moltnet_list_task_attempts", "moltnet_list_task_messages", "moltnet_upload_task_artifact", "moltnet_list_task_artifacts", "moltnet_download_task_artifact", "moltnet_review_session_errors", "moltnet_host_exec"];
745
754
 
746
755
  declare type MoltNetAgent = Awaited<ReturnType<typeof connect>>;
@@ -1072,6 +1081,8 @@ declare interface ResolveSessionToolPolicyInput {
1072
1081
  agent: AllowedToolsClient;
1073
1082
  profileId: string;
1074
1083
  teamId: string;
1084
+ /** Runtime kind supplied by the trusted daemon adapter for this session. */
1085
+ runtimeKind: string;
1075
1086
  /**
1076
1087
  * The profile's enforcement mode, already known to the daemon from the
1077
1088
  * resolved runtime profile. Used to decide fail-open vs fail-closed when the
@@ -1131,6 +1142,32 @@ declare interface RuntimeInstructorContext {
1131
1142
  guestWorkspace: string;
1132
1143
  /** Optional correlation id grouping this task with others. */
1133
1144
  correlationId: string | null;
1145
+ /** Effective, session-start policy projected into model-visible guidance. */
1146
+ toolPolicy?: RuntimeInstructorToolPolicy;
1147
+ sandbox?: RuntimeInstructorSandbox;
1148
+ }
1149
+
1150
+ declare interface RuntimeInstructorSandbox {
1151
+ workspaceMode: 'shared_mount' | 'dedicated_worktree' | 'scratch_mount';
1152
+ vfsShadowMode: 'none' | 'deny' | 'tmpfs';
1153
+ vfsShadowPatterns: readonly string[];
1154
+ nodeModulesWriteMode?: 'tmpfs';
1155
+ verifiedExecutables: readonly string[];
1156
+ allowedHosts: readonly string[];
1157
+ allowedInternalHosts: readonly string[];
1158
+ }
1159
+
1160
+ declare interface RuntimeInstructorToolPolicy {
1161
+ enforcement: 'off' | 'watch' | 'enforce';
1162
+ allowedTools: readonly string[];
1163
+ allowedShellCommands: readonly {
1164
+ argvPrefix: readonly string[];
1165
+ }[];
1166
+ unavailableTools?: readonly string[];
1167
+ unavailableShellCommands?: readonly {
1168
+ argvPrefix: readonly string[];
1169
+ }[];
1170
+ degraded: boolean;
1134
1171
  }
1135
1172
 
1136
1173
  export declare interface SandboxConfig {