@themoltnet/pi-extension 0.27.3 → 0.28.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.
- package/dist/index.d.ts +36 -0
- package/dist/index.js +186 -3
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,16 @@ declare interface BuildAgentSessionArgs {
|
|
|
40
40
|
piAuthDir: string;
|
|
41
41
|
/** Resolved pi model handle (provider + model id). */
|
|
42
42
|
modelHandle: Model<Api>;
|
|
43
|
+
/** Optional runtime-profile thinking/reasoning level applied at session start. */
|
|
44
|
+
thinkingLevel?: PiThinkingLevel | null;
|
|
45
|
+
/** Optional runtime-profile sampling temperature applied to provider requests. */
|
|
46
|
+
temperature?: number | null;
|
|
47
|
+
/** Optional runtime-profile nucleus sampling probability mass. */
|
|
48
|
+
topP?: number | null;
|
|
49
|
+
/** Optional runtime-profile top-k sampling cutoff. */
|
|
50
|
+
topK?: number | null;
|
|
51
|
+
/** Optional runtime-profile generated output token cap. */
|
|
52
|
+
maxOutputTokens?: number | null;
|
|
43
53
|
/** Pre-built customTools array. Caller composes Gondolin + MoltNet + submit tools. */
|
|
44
54
|
customTools: ToolDefinition[];
|
|
45
55
|
/** System-prompt fragments appended after pi's defaults. Parent passes the
|
|
@@ -157,6 +167,16 @@ export declare interface CreateSubagentToolArgs {
|
|
|
157
167
|
piAuthDir: string;
|
|
158
168
|
/** Resolved pi model handle — subagents share it. */
|
|
159
169
|
modelHandle: Model<Api>;
|
|
170
|
+
/** Runtime-profile thinking/reasoning level — subagents inherit it. */
|
|
171
|
+
thinkingLevel?: PiThinkingLevel | null;
|
|
172
|
+
/** Runtime-profile sampling temperature — subagents inherit it. */
|
|
173
|
+
temperature?: number | null;
|
|
174
|
+
/** Runtime-profile nucleus sampling probability mass — subagents inherit it. */
|
|
175
|
+
topP?: number | null;
|
|
176
|
+
/** Runtime-profile top-k sampling cutoff — subagents inherit it. */
|
|
177
|
+
topK?: number | null;
|
|
178
|
+
/** Runtime-profile generated output token cap — subagents inherit it. */
|
|
179
|
+
maxOutputTokens?: number | null;
|
|
160
180
|
/** Agent name for telemetry. */
|
|
161
181
|
agentName: string;
|
|
162
182
|
/**
|
|
@@ -256,6 +276,20 @@ export declare interface ExecutePiTaskOptions {
|
|
|
256
276
|
/** LLM selection. */
|
|
257
277
|
provider: string;
|
|
258
278
|
model: string;
|
|
279
|
+
/**
|
|
280
|
+
* Runtime-profile reasoning/thinking level. Null/undefined means use Pi's
|
|
281
|
+
* configured default; explicit `off` disables provider thinking where
|
|
282
|
+
* supported.
|
|
283
|
+
*/
|
|
284
|
+
thinkingLevel?: PiThinkingLevel | null;
|
|
285
|
+
/** Optional sampling temperature. Null/undefined means provider default. */
|
|
286
|
+
temperature?: number | null;
|
|
287
|
+
/** Optional nucleus-sampling probability mass. Null/undefined means provider default. */
|
|
288
|
+
topP?: number | null;
|
|
289
|
+
/** Optional top-k sampling cutoff. Null/undefined means provider default. */
|
|
290
|
+
topK?: number | null;
|
|
291
|
+
/** Optional cap on generated output tokens. Null/undefined means provider/model default. */
|
|
292
|
+
maxOutputTokens?: number | null;
|
|
259
293
|
/** Extra hosts to allow in the sandbox egress policy. */
|
|
260
294
|
extraAllowedHosts?: string[];
|
|
261
295
|
/** Sandbox overrides (env, VFS shadows, resources). */
|
|
@@ -544,6 +578,8 @@ export declare interface PiTaskExecutionPlan {
|
|
|
544
578
|
|
|
545
579
|
export declare type PiTaskExecutionPlanFactory = (claimedTask: ClaimedTask) => Promise<PiTaskExecutionPlan | null> | PiTaskExecutionPlan | null;
|
|
546
580
|
|
|
581
|
+
declare type PiThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
582
|
+
|
|
547
583
|
declare interface PiWorkspaceAttachmentPlan {
|
|
548
584
|
mountPath: string;
|
|
549
585
|
cwdPath: string;
|
package/dist/index.js
CHANGED
|
@@ -1868,6 +1868,28 @@ var uploadRuntimeSession = (options) => (options.client ?? client).put({
|
|
|
1868
1868
|
}
|
|
1869
1869
|
});
|
|
1870
1870
|
/**
|
|
1871
|
+
* List recent team-scoped runtime slots for repair/sync.
|
|
1872
|
+
*/
|
|
1873
|
+
var listRuntimeSlots = (options) => (options.client ?? client).get({
|
|
1874
|
+
security: [
|
|
1875
|
+
{
|
|
1876
|
+
scheme: "bearer",
|
|
1877
|
+
type: "http"
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
name: "X-Moltnet-Session-Token",
|
|
1881
|
+
type: "apiKey"
|
|
1882
|
+
},
|
|
1883
|
+
{
|
|
1884
|
+
in: "cookie",
|
|
1885
|
+
name: "ory_kratos_session",
|
|
1886
|
+
type: "apiKey"
|
|
1887
|
+
}
|
|
1888
|
+
],
|
|
1889
|
+
url: "/runtime-slots",
|
|
1890
|
+
...options
|
|
1891
|
+
});
|
|
1892
|
+
/**
|
|
1871
1893
|
* Upsert a team-scoped runtime slot for audit and continuation affinity lookup.
|
|
1872
1894
|
*/
|
|
1873
1895
|
var beginRuntimeSlot = (options) => (options.client ?? client).post({
|
|
@@ -5171,6 +5193,15 @@ function createRuntimeSlotsNamespace(context) {
|
|
|
5171
5193
|
if (err instanceof MoltNetError && err.statusCode === 404) return null;
|
|
5172
5194
|
throw err;
|
|
5173
5195
|
}
|
|
5196
|
+
},
|
|
5197
|
+
async list(query, options) {
|
|
5198
|
+
const filteredQuery = Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0));
|
|
5199
|
+
return unwrapResult(await listRuntimeSlots({
|
|
5200
|
+
auth,
|
|
5201
|
+
client,
|
|
5202
|
+
headers: requiredTeamHeaders(options),
|
|
5203
|
+
query: filteredQuery
|
|
5204
|
+
})).items;
|
|
5174
5205
|
}
|
|
5175
5206
|
};
|
|
5176
5207
|
}
|
|
@@ -9520,6 +9551,32 @@ var RuntimeProfileAllowedWorkspaceModes = _Array_(RuntimeProfileWorkspaceMode, {
|
|
|
9520
9551
|
maxItems: 3,
|
|
9521
9552
|
uniqueItems: true
|
|
9522
9553
|
});
|
|
9554
|
+
var RuntimeProfileThinkingLevelOptions = [
|
|
9555
|
+
Literal("off"),
|
|
9556
|
+
Literal("minimal"),
|
|
9557
|
+
Literal("low"),
|
|
9558
|
+
Literal("medium"),
|
|
9559
|
+
Literal("high"),
|
|
9560
|
+
Literal("xhigh")
|
|
9561
|
+
];
|
|
9562
|
+
Union([...RuntimeProfileThinkingLevelOptions]);
|
|
9563
|
+
var RuntimeProfileNullableThinkingLevel = Union([...RuntimeProfileThinkingLevelOptions, Null()]);
|
|
9564
|
+
var RuntimeProfileNullableTemperature = Union([Null(), Number$1({
|
|
9565
|
+
minimum: 0,
|
|
9566
|
+
maximum: 2
|
|
9567
|
+
})]);
|
|
9568
|
+
var RuntimeProfileNullableTopP = Union([Null(), Number$1({
|
|
9569
|
+
minimum: 0,
|
|
9570
|
+
maximum: 1
|
|
9571
|
+
})]);
|
|
9572
|
+
var RuntimeProfileNullableTopK = Union([Integer({
|
|
9573
|
+
minimum: 1,
|
|
9574
|
+
maximum: 1e4
|
|
9575
|
+
}), Null()]);
|
|
9576
|
+
var RuntimeProfileNullableMaxOutputTokens = Union([Integer({
|
|
9577
|
+
minimum: 1,
|
|
9578
|
+
maximum: 1e6
|
|
9579
|
+
}), Null()]);
|
|
9523
9580
|
var SandboxResumeCommandWhenSchema = _Object_({ workspaceMode: Optional(_Array_(Union([
|
|
9524
9581
|
Literal("shared_mount"),
|
|
9525
9582
|
Literal("dedicated_worktree"),
|
|
@@ -9644,6 +9701,11 @@ _Object_({
|
|
|
9644
9701
|
minLength: 1,
|
|
9645
9702
|
maxLength: 200
|
|
9646
9703
|
}),
|
|
9704
|
+
thinkingLevel: RuntimeProfileNullableThinkingLevel,
|
|
9705
|
+
temperature: RuntimeProfileNullableTemperature,
|
|
9706
|
+
topP: RuntimeProfileNullableTopP,
|
|
9707
|
+
topK: RuntimeProfileNullableTopK,
|
|
9708
|
+
maxOutputTokens: RuntimeProfileNullableMaxOutputTokens,
|
|
9647
9709
|
runtimeKind: Literal("gondolin_pi"),
|
|
9648
9710
|
sandbox: RuntimeProfileSandbox,
|
|
9649
9711
|
sessionStorageMode: Literal("local"),
|
|
@@ -9755,7 +9817,7 @@ var RuntimeWorkspace = _Object_({
|
|
|
9755
9817
|
createdAtMs: Integer({ minimum: 0 }),
|
|
9756
9818
|
lastUsedAtMs: Integer({ minimum: 0 })
|
|
9757
9819
|
}, { $id: "RuntimeWorkspace" });
|
|
9758
|
-
_Object_({
|
|
9820
|
+
_Object_({ items: _Array_(_Object_({
|
|
9759
9821
|
slot: _Object_({
|
|
9760
9822
|
id: String$1({ format: "uuid" }),
|
|
9761
9823
|
teamId: String$1({ format: "uuid" }),
|
|
@@ -9788,7 +9850,7 @@ _Object_({
|
|
|
9788
9850
|
expiresAtMs: Integer({ minimum: 0 })
|
|
9789
9851
|
}, { $id: "RuntimeSlot" }),
|
|
9790
9852
|
workspace: Union([RuntimeWorkspace, Null()])
|
|
9791
|
-
}, { $id: "ResolvedRuntimeSlot" });
|
|
9853
|
+
}, { $id: "ResolvedRuntimeSlot" })) }, { $id: "RuntimeSlotListResponse" });
|
|
9792
9854
|
_Object_({
|
|
9793
9855
|
agentName: String$1({
|
|
9794
9856
|
minLength: 1,
|
|
@@ -9849,6 +9911,21 @@ _Object_({
|
|
|
9849
9911
|
$id: "FindLatestRuntimeSlotForAttemptQuery",
|
|
9850
9912
|
additionalProperties: false
|
|
9851
9913
|
});
|
|
9914
|
+
_Object_({
|
|
9915
|
+
agentName: Optional(String$1({
|
|
9916
|
+
minLength: 1,
|
|
9917
|
+
maxLength: 100
|
|
9918
|
+
})),
|
|
9919
|
+
runtimeProfileId: Optional(String$1({ format: "uuid" })),
|
|
9920
|
+
state: Optional(RuntimeSlotState),
|
|
9921
|
+
limit: Optional(Integer({
|
|
9922
|
+
minimum: 1,
|
|
9923
|
+
maximum: 200
|
|
9924
|
+
}))
|
|
9925
|
+
}, {
|
|
9926
|
+
$id: "ListRuntimeSlotsQuery",
|
|
9927
|
+
additionalProperties: false
|
|
9928
|
+
});
|
|
9852
9929
|
//#endregion
|
|
9853
9930
|
//#region ../tasks/src/success-criteria.ts
|
|
9854
9931
|
/**
|
|
@@ -18755,6 +18832,89 @@ function extractUsage(message) {
|
|
|
18755
18832
|
};
|
|
18756
18833
|
}
|
|
18757
18834
|
//#endregion
|
|
18835
|
+
//#region src/runtime/model-options-extension.ts
|
|
18836
|
+
function hasPiModelOptions(options) {
|
|
18837
|
+
return options.temperature !== void 0 && options.temperature !== null || options.topP !== void 0 && options.topP !== null || options.topK !== void 0 && options.topK !== null || options.maxOutputTokens !== void 0 && options.maxOutputTokens !== null;
|
|
18838
|
+
}
|
|
18839
|
+
function createPiModelOptionsExtension(options) {
|
|
18840
|
+
return function piModelOptionsExtension(pi) {
|
|
18841
|
+
pi.on("before_provider_request", (event) => {
|
|
18842
|
+
return applyPiModelOptions(event.payload, options);
|
|
18843
|
+
});
|
|
18844
|
+
};
|
|
18845
|
+
}
|
|
18846
|
+
function applyPiModelOptions(payload, options) {
|
|
18847
|
+
if (!isRecord(payload)) return void 0;
|
|
18848
|
+
if (!hasPiModelOptions(options)) return void 0;
|
|
18849
|
+
if (isGooglePayload(payload)) {
|
|
18850
|
+
const config = isRecord(payload.config) ? payload.config : {};
|
|
18851
|
+
return {
|
|
18852
|
+
...payload,
|
|
18853
|
+
config: applyConfigOptions(config, options)
|
|
18854
|
+
};
|
|
18855
|
+
}
|
|
18856
|
+
if (isBedrockPayload(payload)) {
|
|
18857
|
+
const inferenceConfig = isRecord(payload.inferenceConfig) ? payload.inferenceConfig : {};
|
|
18858
|
+
return {
|
|
18859
|
+
...payload,
|
|
18860
|
+
inferenceConfig: applyBedrockOptions(inferenceConfig, options)
|
|
18861
|
+
};
|
|
18862
|
+
}
|
|
18863
|
+
return applyTopLevelOptions(payload, options);
|
|
18864
|
+
}
|
|
18865
|
+
function applyConfigOptions(config, options) {
|
|
18866
|
+
return {
|
|
18867
|
+
...config,
|
|
18868
|
+
...options.temperature !== void 0 && options.temperature !== null ? { temperature: options.temperature } : {},
|
|
18869
|
+
...options.topP !== void 0 && options.topP !== null ? { topP: options.topP } : {},
|
|
18870
|
+
...options.topK !== void 0 && options.topK !== null ? { topK: options.topK } : {},
|
|
18871
|
+
...options.maxOutputTokens !== void 0 && options.maxOutputTokens !== null ? { maxOutputTokens: options.maxOutputTokens } : {}
|
|
18872
|
+
};
|
|
18873
|
+
}
|
|
18874
|
+
function applyBedrockOptions(inferenceConfig, options) {
|
|
18875
|
+
return {
|
|
18876
|
+
...inferenceConfig,
|
|
18877
|
+
...options.temperature !== void 0 && options.temperature !== null ? { temperature: options.temperature } : {},
|
|
18878
|
+
...options.topP !== void 0 && options.topP !== null ? { topP: options.topP } : {},
|
|
18879
|
+
...options.maxOutputTokens !== void 0 && options.maxOutputTokens !== null ? { maxTokens: options.maxOutputTokens } : {}
|
|
18880
|
+
};
|
|
18881
|
+
}
|
|
18882
|
+
function applyTopLevelOptions(payload, options) {
|
|
18883
|
+
const reasoningEnabled = hasActiveThinking(payload.thinking) || "reasoning" in payload || "reasoning_effort" in payload;
|
|
18884
|
+
const next = { ...payload };
|
|
18885
|
+
if (options.temperature !== void 0 && options.temperature !== null && !reasoningEnabled) next.temperature = options.temperature;
|
|
18886
|
+
if (options.topP !== void 0 && options.topP !== null && !reasoningEnabled) next.top_p = options.topP;
|
|
18887
|
+
if (options.topK !== void 0 && options.topK !== null && !reasoningEnabled && isAnthropicPayload(next)) next.top_k = options.topK;
|
|
18888
|
+
if (options.maxOutputTokens !== void 0 && options.maxOutputTokens !== null) {
|
|
18889
|
+
const maxOutputTokens = options.maxOutputTokens;
|
|
18890
|
+
if ("max_output_tokens" in next || isResponsesPayload(next)) next.max_output_tokens = maxOutputTokens;
|
|
18891
|
+
else if ("max_completion_tokens" in next) next.max_completion_tokens = maxOutputTokens;
|
|
18892
|
+
else if ("maxTokens" in next) next.maxTokens = maxOutputTokens;
|
|
18893
|
+
else next.max_tokens = maxOutputTokens;
|
|
18894
|
+
}
|
|
18895
|
+
return next;
|
|
18896
|
+
}
|
|
18897
|
+
function isGooglePayload(payload) {
|
|
18898
|
+
return "contents" in payload && ("config" in payload || "model" in payload);
|
|
18899
|
+
}
|
|
18900
|
+
function isBedrockPayload(payload) {
|
|
18901
|
+
return "inferenceConfig" in payload || "additionalModelRequestFields" in payload;
|
|
18902
|
+
}
|
|
18903
|
+
function isResponsesPayload(payload) {
|
|
18904
|
+
return "input" in payload && !("messages" in payload);
|
|
18905
|
+
}
|
|
18906
|
+
function isAnthropicPayload(payload) {
|
|
18907
|
+
return "anthropic_version" in payload;
|
|
18908
|
+
}
|
|
18909
|
+
function hasActiveThinking(value) {
|
|
18910
|
+
if (!isRecord(value)) return false;
|
|
18911
|
+
const type = value.type;
|
|
18912
|
+
return type !== "disabled" && type !== "off" && type !== false;
|
|
18913
|
+
}
|
|
18914
|
+
function isRecord(value) {
|
|
18915
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18916
|
+
}
|
|
18917
|
+
//#endregion
|
|
18758
18918
|
//#region src/runtime/agent-session-factory.ts
|
|
18759
18919
|
var NO_SKILLS = () => ({
|
|
18760
18920
|
skills: [],
|
|
@@ -18772,10 +18932,17 @@ async function buildAgentSession(args) {
|
|
|
18772
18932
|
agentName: args.agentName,
|
|
18773
18933
|
spanAttributes: args.otelSpanAttrs
|
|
18774
18934
|
});
|
|
18935
|
+
const modelOptions = {
|
|
18936
|
+
temperature: args.temperature,
|
|
18937
|
+
topP: args.topP,
|
|
18938
|
+
topK: args.topK,
|
|
18939
|
+
maxOutputTokens: args.maxOutputTokens
|
|
18940
|
+
};
|
|
18941
|
+
const extensionFactories = hasPiModelOptions(modelOptions) ? [piOtelExtension, createPiModelOptionsExtension(modelOptions)] : [piOtelExtension];
|
|
18775
18942
|
const resourceLoader = new DefaultResourceLoader({
|
|
18776
18943
|
cwd: args.cwdPath,
|
|
18777
18944
|
agentDir: args.piAuthDir,
|
|
18778
|
-
extensionFactories
|
|
18945
|
+
extensionFactories,
|
|
18779
18946
|
appendSystemPrompt: args.appendSystemPrompt,
|
|
18780
18947
|
skillsOverride: args.skillsOverride ?? NO_SKILLS
|
|
18781
18948
|
});
|
|
@@ -18789,6 +18956,7 @@ async function buildAgentSession(args) {
|
|
|
18789
18956
|
agentDir: args.piAuthDir,
|
|
18790
18957
|
cwd: args.cwdPath,
|
|
18791
18958
|
model: args.modelHandle,
|
|
18959
|
+
thinkingLevel: args.thinkingLevel ?? void 0,
|
|
18792
18960
|
customTools: args.customTools,
|
|
18793
18961
|
sessionManager,
|
|
18794
18962
|
resourceLoader
|
|
@@ -24052,6 +24220,11 @@ function createSubagentTool(args) {
|
|
|
24052
24220
|
cwdPath: args.cwdPath ?? args.mountPath,
|
|
24053
24221
|
piAuthDir: args.piAuthDir,
|
|
24054
24222
|
modelHandle: args.modelHandle,
|
|
24223
|
+
thinkingLevel: args.thinkingLevel,
|
|
24224
|
+
temperature: args.temperature,
|
|
24225
|
+
topP: args.topP,
|
|
24226
|
+
topK: args.topK,
|
|
24227
|
+
maxOutputTokens: args.maxOutputTokens,
|
|
24055
24228
|
agentName: args.agentName,
|
|
24056
24229
|
customTools: [...args.inheritedCustomTools, submitTool],
|
|
24057
24230
|
appendSystemPrompt: [args.parentRuntimeInstructor, subagentInstructor],
|
|
@@ -24936,6 +25109,11 @@ async function executePiTask(claimedTask, reporter, opts) {
|
|
|
24936
25109
|
cwdPath,
|
|
24937
25110
|
piAuthDir,
|
|
24938
25111
|
modelHandle,
|
|
25112
|
+
thinkingLevel: opts.thinkingLevel,
|
|
25113
|
+
temperature: opts.temperature,
|
|
25114
|
+
topP: opts.topP,
|
|
25115
|
+
topK: opts.topK,
|
|
25116
|
+
maxOutputTokens: opts.maxOutputTokens,
|
|
24939
25117
|
agentName: opts.agentName,
|
|
24940
25118
|
inheritedCustomTools: [...gondolinCustomTools, ...moltnetTools],
|
|
24941
25119
|
parentRuntimeInstructor: runtimeInstructor,
|
|
@@ -24952,6 +25130,11 @@ async function executePiTask(claimedTask, reporter, opts) {
|
|
|
24952
25130
|
cwdPath,
|
|
24953
25131
|
piAuthDir,
|
|
24954
25132
|
modelHandle,
|
|
25133
|
+
thinkingLevel: opts.thinkingLevel,
|
|
25134
|
+
temperature: opts.temperature,
|
|
25135
|
+
topP: opts.topP,
|
|
25136
|
+
topK: opts.topK,
|
|
25137
|
+
maxOutputTokens: opts.maxOutputTokens,
|
|
24955
25138
|
agentName: opts.agentName,
|
|
24956
25139
|
customTools: [
|
|
24957
25140
|
...gondolinCustomTools,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/pi-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MoltNet pi extension — sandboxed tool execution in Gondolin VMs with MoltNet identity and persistent memory",
|
|
6
6
|
"keywords": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@earendil-works/gondolin": "^0.9.1",
|
|
37
37
|
"@opentelemetry/api": "^1.9.0",
|
|
38
38
|
"typebox": "^1.2.8",
|
|
39
|
-
"@themoltnet/
|
|
40
|
-
"@themoltnet/
|
|
39
|
+
"@themoltnet/agent-runtime": "0.31.1",
|
|
40
|
+
"@themoltnet/sdk": "0.114.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@earendil-works/pi-coding-agent": ">=0.74.0",
|
|
@@ -61,8 +61,7 @@
|
|
|
61
61
|
"vite": "^8.0.0",
|
|
62
62
|
"vite-plugin-dts": "^4.5.4",
|
|
63
63
|
"vitest": "^3.0.0",
|
|
64
|
-
"@moltnet/crypto-service": "0.1.0"
|
|
65
|
-
"@moltnet/tasks": "0.1.0"
|
|
64
|
+
"@moltnet/crypto-service": "0.1.0"
|
|
66
65
|
},
|
|
67
66
|
"engines": {
|
|
68
67
|
"node": ">=22"
|