@themoltnet/pi-extension 0.27.2 → 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 +206 -35
- 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
|
/**
|
|
@@ -10269,6 +10346,7 @@ var FreeformArtifact = _Object_({
|
|
|
10269
10346
|
});
|
|
10270
10347
|
var FreeformOutput = _Object_({
|
|
10271
10348
|
summary: String$1({ minLength: 1 }),
|
|
10349
|
+
branch: Optional(String$1({ minLength: 1 })),
|
|
10272
10350
|
artifacts: Optional(_Array_(FreeformArtifact, { maxItems: 20 })),
|
|
10273
10351
|
proposedTaskType: Optional(FreeformTaskTypeProposal),
|
|
10274
10352
|
diaryEntryIds: Optional(_Array_(String$1({ format: "uuid" }))),
|
|
@@ -10281,7 +10359,7 @@ var FreeformOutput = _Object_({
|
|
|
10281
10359
|
* Server-side preflight for `freeform` task-create. Runs after the
|
|
10282
10360
|
* sync TypeBox check passes and only kicks in when
|
|
10283
10361
|
* `input.continueFrom` is set — i.e. the proposer is asking to
|
|
10284
|
-
*
|
|
10362
|
+
* continue from a prior freeform attempt (#1287).
|
|
10285
10363
|
*
|
|
10286
10364
|
* Failure modes, in evaluation order:
|
|
10287
10365
|
* 1. `freeform.sourceTaskNotFound` — source task id does not resolve
|
|
@@ -10289,23 +10367,17 @@ var FreeformOutput = _Object_({
|
|
|
10289
10367
|
* 2. `freeform.sourceTaskTypeNotSupported` — source isn't `freeform`.
|
|
10290
10368
|
* v1 only supports freeform → freeform continuation.
|
|
10291
10369
|
* 3. `freeform.sourceAttemptNotCompleted` — named attempt is missing
|
|
10292
|
-
* or not in `completed` state;
|
|
10370
|
+
* or not in `completed` state; continuation only makes sense
|
|
10293
10371
|
* once the parent has produced a terminal output.
|
|
10294
10372
|
* 4. `freeform.executionWorkspaceNotInheritable` — caller set
|
|
10295
10373
|
* `execution.workspace` together with `continueFrom`. Workspace
|
|
10296
|
-
* mode for a continuation is
|
|
10297
|
-
* (
|
|
10298
|
-
*
|
|
10299
|
-
*
|
|
10300
|
-
*
|
|
10301
|
-
* 5. `freeform.sourceNotResumeEligible` — `daemonState` is null or
|
|
10302
|
-
* `slotResumableUntil` is null. Older completions (pre-#1287) and
|
|
10303
|
-
* daemons that opt out fall here.
|
|
10304
|
-
* 6. `freeform.sourceResumeExpired` — `slotResumableUntil` is in the
|
|
10305
|
-
* past; the warm slot's TTL has elapsed and no daemon is
|
|
10306
|
-
* guaranteed to still hold it.
|
|
10374
|
+
* mode for a continuation is derived by the daemon from parent runtime
|
|
10375
|
+
* context (local slot first, durable session + source attempt branch
|
|
10376
|
+
* second), so any caller-supplied override is silently dropped at the
|
|
10377
|
+
* daemon plan stage. Reject explicitly so misconfiguration surfaces at
|
|
10378
|
+
* create time.
|
|
10307
10379
|
*
|
|
10308
|
-
* Returns on the first failure
|
|
10380
|
+
* Returns on the first failure — the checks
|
|
10309
10381
|
* are sequential preconditions, later ones presume earlier ones hold.
|
|
10310
10382
|
*/
|
|
10311
10383
|
async function validateFreeformInputAsync(input, ctx) {
|
|
@@ -10324,7 +10396,7 @@ async function validateFreeformInputAsync(input, ctx) {
|
|
|
10324
10396
|
}];
|
|
10325
10397
|
if (input.execution?.workspace) return [{
|
|
10326
10398
|
field: "input/execution/workspace",
|
|
10327
|
-
message: "execution.workspace is
|
|
10399
|
+
message: "execution.workspace is derived from parent runtime context when continueFrom is set; omit it",
|
|
10328
10400
|
code: "freeform.executionWorkspaceNotInheritable"
|
|
10329
10401
|
}];
|
|
10330
10402
|
if (ctx.deferReadinessChecks) return [];
|
|
@@ -10334,17 +10406,6 @@ async function validateFreeformInputAsync(input, ctx) {
|
|
|
10334
10406
|
message: `Source attempt ${cf.attemptN} on task ${cf.taskId} is not in 'completed' state`,
|
|
10335
10407
|
code: "freeform.sourceAttemptNotCompleted"
|
|
10336
10408
|
}];
|
|
10337
|
-
if (!attempt.daemonState || attempt.daemonState.slotResumableUntil === null) return [{
|
|
10338
|
-
field: "input/continueFrom",
|
|
10339
|
-
message: "Source attempt did not report continuation eligibility (older completion or daemon opted out)",
|
|
10340
|
-
code: "freeform.sourceNotResumeEligible"
|
|
10341
|
-
}];
|
|
10342
|
-
const expiresAt = new Date(attempt.daemonState.slotResumableUntil).getTime();
|
|
10343
|
-
if (Number.isNaN(expiresAt) || expiresAt <= Date.now()) return [{
|
|
10344
|
-
field: "input/continueFrom",
|
|
10345
|
-
message: `Source attempt's warm slot expired at ${attempt.daemonState.slotResumableUntil} (reported at ${attempt.daemonState.reportedAt})`,
|
|
10346
|
-
code: "freeform.sourceResumeExpired"
|
|
10347
|
-
}];
|
|
10348
10409
|
return [];
|
|
10349
10410
|
}
|
|
10350
10411
|
//#endregion
|
|
@@ -13688,11 +13749,12 @@ var MAX_CLAIM_CONDITION_STATUSES = 8;
|
|
|
13688
13749
|
/**
|
|
13689
13750
|
* Daemon-asserted runtime state stamped onto a `TaskAttemptSummary` at
|
|
13690
13751
|
* attempt-completion time. The server persists this block verbatim and
|
|
13691
|
-
*
|
|
13692
|
-
* eligibility
|
|
13693
|
-
*
|
|
13694
|
-
*
|
|
13695
|
-
*
|
|
13752
|
+
* exposes `slotResumableUntil` as a legacy/local warm-slot hint; task
|
|
13753
|
+
* continuation eligibility is based on the completed source attempt and
|
|
13754
|
+
* daemon-side claim-affinity/runtime-session recovery. The block carries
|
|
13755
|
+
* its own `reportedAt` so consumers can reason about staleness without
|
|
13756
|
+
* reading documentation. All daemon-asserted state lives here —
|
|
13757
|
+
* top-level attempt fields stay server-authoritative.
|
|
13696
13758
|
*
|
|
13697
13759
|
* Adding new fields requires explicit design review (intentional
|
|
13698
13760
|
* boundary; see docs/superpowers/specs/2026-06-04-tasks-continue-design.md).
|
|
@@ -18770,6 +18832,89 @@ function extractUsage(message) {
|
|
|
18770
18832
|
};
|
|
18771
18833
|
}
|
|
18772
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
|
|
18773
18918
|
//#region src/runtime/agent-session-factory.ts
|
|
18774
18919
|
var NO_SKILLS = () => ({
|
|
18775
18920
|
skills: [],
|
|
@@ -18787,10 +18932,17 @@ async function buildAgentSession(args) {
|
|
|
18787
18932
|
agentName: args.agentName,
|
|
18788
18933
|
spanAttributes: args.otelSpanAttrs
|
|
18789
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];
|
|
18790
18942
|
const resourceLoader = new DefaultResourceLoader({
|
|
18791
18943
|
cwd: args.cwdPath,
|
|
18792
18944
|
agentDir: args.piAuthDir,
|
|
18793
|
-
extensionFactories
|
|
18945
|
+
extensionFactories,
|
|
18794
18946
|
appendSystemPrompt: args.appendSystemPrompt,
|
|
18795
18947
|
skillsOverride: args.skillsOverride ?? NO_SKILLS
|
|
18796
18948
|
});
|
|
@@ -18804,6 +18956,7 @@ async function buildAgentSession(args) {
|
|
|
18804
18956
|
agentDir: args.piAuthDir,
|
|
18805
18957
|
cwd: args.cwdPath,
|
|
18806
18958
|
model: args.modelHandle,
|
|
18959
|
+
thinkingLevel: args.thinkingLevel ?? void 0,
|
|
18807
18960
|
customTools: args.customTools,
|
|
18808
18961
|
sessionManager,
|
|
18809
18962
|
resourceLoader
|
|
@@ -19445,7 +19598,9 @@ function buildFreeformUserPrompt(input, ctx) {
|
|
|
19445
19598
|
"2. Gather enough context to avoid guessing.",
|
|
19446
19599
|
"3. Complete the requested work when it is safe and bounded.",
|
|
19447
19600
|
"4. If the request reveals a recurring task shape, include a",
|
|
19448
|
-
" `proposedTaskType` in the final output with a concise rationale."
|
|
19601
|
+
" `proposedTaskType` in the final output with a concise rationale.",
|
|
19602
|
+
"5. If you changed code on a branch, include that branch in",
|
|
19603
|
+
" `branch` so future continuations can recover git context."
|
|
19449
19604
|
].join("\n");
|
|
19450
19605
|
const sections = [
|
|
19451
19606
|
{
|
|
@@ -19497,6 +19652,7 @@ function buildFreeformUserPrompt(input, ctx) {
|
|
|
19497
19652
|
shapeSketch: [
|
|
19498
19653
|
"{",
|
|
19499
19654
|
" \"summary\": \"<2-5 sentence result>\",",
|
|
19655
|
+
" \"branch\": \"<branch name when code changed; omit for prose-only work>\",",
|
|
19500
19656
|
" \"artifacts\": [{ \"kind\": \"...\", \"title\": \"...\", \"description\": \"...\", \"body\": \"<inline content up to 64 KiB; preferred for textual output so it persists with the task>\", \"url\": \"...\", \"path\": \"<worktree-ephemeral; not persisted after completion>\" }],",
|
|
19501
19657
|
" \"proposedTaskType\": { \"name\": \"...\", \"rationale\": \"...\", \"inputShape\": {}, \"outputShape\": {} },",
|
|
19502
19658
|
" \"diaryEntryIds\": [\"...\"],",
|
|
@@ -24064,6 +24220,11 @@ function createSubagentTool(args) {
|
|
|
24064
24220
|
cwdPath: args.cwdPath ?? args.mountPath,
|
|
24065
24221
|
piAuthDir: args.piAuthDir,
|
|
24066
24222
|
modelHandle: args.modelHandle,
|
|
24223
|
+
thinkingLevel: args.thinkingLevel,
|
|
24224
|
+
temperature: args.temperature,
|
|
24225
|
+
topP: args.topP,
|
|
24226
|
+
topK: args.topK,
|
|
24227
|
+
maxOutputTokens: args.maxOutputTokens,
|
|
24067
24228
|
agentName: args.agentName,
|
|
24068
24229
|
customTools: [...args.inheritedCustomTools, submitTool],
|
|
24069
24230
|
appendSystemPrompt: [args.parentRuntimeInstructor, subagentInstructor],
|
|
@@ -24948,6 +25109,11 @@ async function executePiTask(claimedTask, reporter, opts) {
|
|
|
24948
25109
|
cwdPath,
|
|
24949
25110
|
piAuthDir,
|
|
24950
25111
|
modelHandle,
|
|
25112
|
+
thinkingLevel: opts.thinkingLevel,
|
|
25113
|
+
temperature: opts.temperature,
|
|
25114
|
+
topP: opts.topP,
|
|
25115
|
+
topK: opts.topK,
|
|
25116
|
+
maxOutputTokens: opts.maxOutputTokens,
|
|
24951
25117
|
agentName: opts.agentName,
|
|
24952
25118
|
inheritedCustomTools: [...gondolinCustomTools, ...moltnetTools],
|
|
24953
25119
|
parentRuntimeInstructor: runtimeInstructor,
|
|
@@ -24964,6 +25130,11 @@ async function executePiTask(claimedTask, reporter, opts) {
|
|
|
24964
25130
|
cwdPath,
|
|
24965
25131
|
piAuthDir,
|
|
24966
25132
|
modelHandle,
|
|
25133
|
+
thinkingLevel: opts.thinkingLevel,
|
|
25134
|
+
temperature: opts.temperature,
|
|
25135
|
+
topP: opts.topP,
|
|
25136
|
+
topK: opts.topK,
|
|
25137
|
+
maxOutputTokens: opts.maxOutputTokens,
|
|
24967
25138
|
agentName: opts.agentName,
|
|
24968
25139
|
customTools: [
|
|
24969
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/agent-runtime": "0.
|
|
40
|
-
"@themoltnet/sdk": "0.
|
|
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"
|