@themoltnet/pi-runtime 0.4.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 +54 -20
  2. package/dist/index.js +494 -525
  3. package/package.json +8 -8
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';
@@ -69,6 +70,8 @@ declare interface BuildAgentSessionArgs {
69
70
  piAuthDir: string;
70
71
  /** Resolved pi model handle (provider + model id). */
71
72
  modelHandle: Model<Api>;
73
+ /** Registry that resolved modelHandle, including custom providers/auth. */
74
+ modelRegistry?: ModelRegistry;
72
75
  /** Optional runtime-profile thinking/reasoning level applied at session start. */
73
76
  thinkingLevel?: PiThinkingLevel | null;
74
77
  /** Optional runtime-profile sampling temperature applied to provider requests. */
@@ -189,6 +192,8 @@ export declare interface CreateSubagentToolArgs {
189
192
  piAuthDir: string;
190
193
  /** Resolved pi model handle — subagents share it. */
191
194
  modelHandle: Model<Api>;
195
+ /** Registry that resolved modelHandle — subagents share it. */
196
+ modelRegistry?: ModelRegistry;
192
197
  /** Runtime-profile thinking/reasoning level — subagents inherit it. */
193
198
  thinkingLevel?: PiThinkingLevel | null;
194
199
  /** Runtime-profile sampling temperature — subagents inherit it. */
@@ -349,10 +354,7 @@ export declare function definePiTool(options: PiToolFactoryOptions): PiToolContr
349
354
  export declare function enabledPiToolNames(input: {
350
355
  tools: readonly ToolDefinition[];
351
356
  extensions?: readonly PiExtensionContribution[];
352
- policy?: {
353
- enforcement: ToolEnforcement;
354
- allowedTools: ReadonlySet<string>;
355
- };
357
+ policy?: ModelVisibleToolPolicy;
356
358
  }): string[] | undefined;
357
359
 
358
360
  /**
@@ -576,10 +578,7 @@ export declare interface ExecutePiTaskOptions {
576
578
  resolveVmTemplate?: () => Promise<ResolvedGondolinTemplate>;
577
579
  }
578
580
 
579
- export declare function filterModelVisibleTools(tools: readonly ToolDefinition[], policy?: {
580
- enforcement: ToolEnforcement;
581
- allowedTools: ReadonlySet<string>;
582
- }): ToolDefinition[];
581
+ export declare function filterModelVisibleTools(tools: readonly ToolDefinition[], policy?: ModelVisibleToolPolicy): ToolDefinition[];
583
582
 
584
583
  /**
585
584
  * Resolve the main worktree root (where .moltnet/ lives — it's untracked,
@@ -689,10 +688,17 @@ export declare interface InjectTaskContextArgs {
689
688
 
690
689
  export declare function isKernelTool(name: string): boolean;
691
690
 
692
- export declare function isToolVisible(name: string, policy?: {
693
- enforcement: ToolEnforcement;
694
- allowedTools: ReadonlySet<string>;
695
- }): 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;
696
702
 
697
703
  export declare function loadCredentials(agentDir: string): VmCredentials;
698
704
 
@@ -714,20 +720,14 @@ export declare function materializePiExtensions(input: {
714
720
  runtime: PiRuntimeDefinition;
715
721
  context: PiToolContext;
716
722
  target: 'parent' | 'subagent';
717
- policy?: {
718
- enforcement: ToolEnforcement;
719
- allowedTools: ReadonlySet<string>;
720
- };
723
+ policy?: ModelVisibleToolPolicy;
721
724
  }): Promise<PiExtensionFactory[]>;
722
725
 
723
726
  export declare function materializePiTools(input: {
724
727
  runtime: PiRuntimeDefinition;
725
728
  context: PiToolContext;
726
729
  target: 'parent' | 'subagent';
727
- policy?: {
728
- enforcement: ToolEnforcement;
729
- allowedTools: ReadonlySet<string>;
730
- };
730
+ policy?: ModelVisibleToolPolicy;
731
731
  }): Promise<ToolDefinition[]>;
732
732
 
733
733
  /**
@@ -742,6 +742,14 @@ declare interface MissingShellCommand {
742
742
  dynamicTokenCount: number;
743
743
  }
744
744
 
745
+ export declare interface ModelVisibleToolPolicy {
746
+ enforcement: ToolEnforcement;
747
+ allowedTools: ReadonlySet<string>;
748
+ allowedShellCommands?: readonly {
749
+ argvPrefix: readonly string[];
750
+ }[];
751
+ }
752
+
745
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"];
746
754
 
747
755
  declare type MoltNetAgent = Awaited<ReturnType<typeof connect>>;
@@ -1134,6 +1142,32 @@ declare interface RuntimeInstructorContext {
1134
1142
  guestWorkspace: string;
1135
1143
  /** Optional correlation id grouping this task with others. */
1136
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;
1137
1171
  }
1138
1172
 
1139
1173
  export declare interface SandboxConfig {