@themoltnet/pi-extension 0.27.0 → 0.27.2
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.js +182 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync,
|
|
|
4
4
|
import path, { join, relative, sep } from "node:path";
|
|
5
5
|
import { DefaultResourceLoader, SessionManager, createAgentSession, createBashTool, createBashToolDefinition, createEditTool, createEditToolDefinition, createReadTool, createReadToolDefinition, createSyntheticSourceInfo, createWriteTool, createWriteToolDefinition, defineTool, parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
7
8
|
import crypto, { createHash as createHash$1 } from "crypto";
|
|
8
9
|
import { readFile } from "node:fs/promises";
|
|
9
10
|
import { homedir } from "node:os";
|
|
@@ -1818,6 +1819,55 @@ var updateRuntimeProfile = (options) => (options.client ?? client).patch({
|
|
|
1818
1819
|
}
|
|
1819
1820
|
});
|
|
1820
1821
|
/**
|
|
1822
|
+
* Get metadata for the durable team-scoped runtime session for a task attempt.
|
|
1823
|
+
*/
|
|
1824
|
+
var getRuntimeSession = (options) => (options.client ?? client).get({
|
|
1825
|
+
security: [
|
|
1826
|
+
{
|
|
1827
|
+
scheme: "bearer",
|
|
1828
|
+
type: "http"
|
|
1829
|
+
},
|
|
1830
|
+
{
|
|
1831
|
+
name: "X-Moltnet-Session-Token",
|
|
1832
|
+
type: "apiKey"
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
in: "cookie",
|
|
1836
|
+
name: "ory_kratos_session",
|
|
1837
|
+
type: "apiKey"
|
|
1838
|
+
}
|
|
1839
|
+
],
|
|
1840
|
+
url: "/runtime-sessions/{taskId}/{attemptN}",
|
|
1841
|
+
...options
|
|
1842
|
+
});
|
|
1843
|
+
/**
|
|
1844
|
+
* Stream or replace the durable team-scoped runtime session content for a task attempt.
|
|
1845
|
+
*/
|
|
1846
|
+
var uploadRuntimeSession = (options) => (options.client ?? client).put({
|
|
1847
|
+
bodySerializer: null,
|
|
1848
|
+
security: [
|
|
1849
|
+
{
|
|
1850
|
+
scheme: "bearer",
|
|
1851
|
+
type: "http"
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
name: "X-Moltnet-Session-Token",
|
|
1855
|
+
type: "apiKey"
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
in: "cookie",
|
|
1859
|
+
name: "ory_kratos_session",
|
|
1860
|
+
type: "apiKey"
|
|
1861
|
+
}
|
|
1862
|
+
],
|
|
1863
|
+
url: "/runtime-sessions/{taskId}/{attemptN}/content",
|
|
1864
|
+
...options,
|
|
1865
|
+
headers: {
|
|
1866
|
+
"Content-Type": "application/octet-stream",
|
|
1867
|
+
...options.headers
|
|
1868
|
+
}
|
|
1869
|
+
});
|
|
1870
|
+
/**
|
|
1821
1871
|
* Upsert a team-scoped runtime slot for audit and continuation affinity lookup.
|
|
1822
1872
|
*/
|
|
1823
1873
|
var beginRuntimeSlot = (options) => (options.client ?? client).post({
|
|
@@ -5038,6 +5088,57 @@ function createRuntimeProfilesNamespace(context) {
|
|
|
5038
5088
|
};
|
|
5039
5089
|
}
|
|
5040
5090
|
//#endregion
|
|
5091
|
+
//#region ../sdk/src/namespaces/runtime-sessions.ts
|
|
5092
|
+
function createRuntimeSessionsNamespace(context) {
|
|
5093
|
+
const { client, auth } = context;
|
|
5094
|
+
return {
|
|
5095
|
+
async getForAttempt(path, options) {
|
|
5096
|
+
try {
|
|
5097
|
+
return unwrapResult(await getRuntimeSession({
|
|
5098
|
+
client,
|
|
5099
|
+
auth,
|
|
5100
|
+
headers: requiredTeamHeaders(options),
|
|
5101
|
+
path
|
|
5102
|
+
}));
|
|
5103
|
+
} catch (err) {
|
|
5104
|
+
if (err instanceof MoltNetError && err.statusCode === 404) return null;
|
|
5105
|
+
throw err;
|
|
5106
|
+
}
|
|
5107
|
+
},
|
|
5108
|
+
async upload(path, body, query, options) {
|
|
5109
|
+
return unwrapResult(await uploadRuntimeSession({
|
|
5110
|
+
auth,
|
|
5111
|
+
body,
|
|
5112
|
+
client,
|
|
5113
|
+
duplex: "half",
|
|
5114
|
+
headers: {
|
|
5115
|
+
...requiredTeamHeaders(options),
|
|
5116
|
+
"content-type": "application/octet-stream"
|
|
5117
|
+
},
|
|
5118
|
+
path,
|
|
5119
|
+
query
|
|
5120
|
+
}));
|
|
5121
|
+
},
|
|
5122
|
+
async download(path, options) {
|
|
5123
|
+
const stream = unwrapResult(await client.request({
|
|
5124
|
+
auth,
|
|
5125
|
+
headers: requiredTeamHeaders(options),
|
|
5126
|
+
method: "GET",
|
|
5127
|
+
parseAs: "stream",
|
|
5128
|
+
path,
|
|
5129
|
+
security: [{
|
|
5130
|
+
scheme: "bearer",
|
|
5131
|
+
type: "http"
|
|
5132
|
+
}],
|
|
5133
|
+
url: "/runtime-sessions/{taskId}/{attemptN}/content"
|
|
5134
|
+
}));
|
|
5135
|
+
if (stream instanceof Readable) return stream;
|
|
5136
|
+
if (stream instanceof ReadableStream) return Readable.fromWeb(stream);
|
|
5137
|
+
throw new MoltNetError("Unexpected runtime session download response stream", { code: "INVALID_RESPONSE" });
|
|
5138
|
+
}
|
|
5139
|
+
};
|
|
5140
|
+
}
|
|
5141
|
+
//#endregion
|
|
5041
5142
|
//#region ../sdk/src/namespaces/runtime-slots.ts
|
|
5042
5143
|
function createRuntimeSlotsNamespace(context) {
|
|
5043
5144
|
const { client, auth } = context;
|
|
@@ -9409,6 +9510,16 @@ var RuntimeProfileToolName = String$1({
|
|
|
9409
9510
|
maxLength: 128,
|
|
9410
9511
|
pattern: "^[a-zA-Z0-9._/-]+$"
|
|
9411
9512
|
});
|
|
9513
|
+
var RuntimeProfileWorkspaceMode = Union([
|
|
9514
|
+
Literal("none"),
|
|
9515
|
+
Literal("shared_mount"),
|
|
9516
|
+
Literal("dedicated_worktree")
|
|
9517
|
+
]);
|
|
9518
|
+
var RuntimeProfileAllowedWorkspaceModes = _Array_(RuntimeProfileWorkspaceMode, {
|
|
9519
|
+
minItems: 1,
|
|
9520
|
+
maxItems: 3,
|
|
9521
|
+
uniqueItems: true
|
|
9522
|
+
});
|
|
9412
9523
|
var SandboxResumeCommandWhenSchema = _Object_({ workspaceMode: Optional(_Array_(Union([
|
|
9413
9524
|
Literal("shared_mount"),
|
|
9414
9525
|
Literal("dedicated_worktree"),
|
|
@@ -9512,6 +9623,14 @@ var RuntimeProfileMaxBatchSize = Integer({
|
|
|
9512
9623
|
minimum: 1,
|
|
9513
9624
|
maximum: 1e3
|
|
9514
9625
|
});
|
|
9626
|
+
var RuntimeProfileMaxTurns = Integer({
|
|
9627
|
+
minimum: 0,
|
|
9628
|
+
maximum: 1e4
|
|
9629
|
+
});
|
|
9630
|
+
var RuntimeProfileMaxBashTimeouts = Integer({
|
|
9631
|
+
minimum: 0,
|
|
9632
|
+
maximum: 1e3
|
|
9633
|
+
});
|
|
9515
9634
|
_Object_({
|
|
9516
9635
|
id: String$1({ format: "uuid" }),
|
|
9517
9636
|
teamId: String$1({ format: "uuid" }),
|
|
@@ -9529,6 +9648,8 @@ _Object_({
|
|
|
9529
9648
|
sandbox: RuntimeProfileSandbox,
|
|
9530
9649
|
sessionStorageMode: Literal("local"),
|
|
9531
9650
|
workspaceStorageMode: Literal("local"),
|
|
9651
|
+
defaultWorkspaceMode: Union([RuntimeProfileWorkspaceMode, Null()]),
|
|
9652
|
+
allowedWorkspaceModes: RuntimeProfileAllowedWorkspaceModes,
|
|
9532
9653
|
sessionTtlSec: Integer({
|
|
9533
9654
|
minimum: 1,
|
|
9534
9655
|
maximum: 86400
|
|
@@ -9540,6 +9661,8 @@ _Object_({
|
|
|
9540
9661
|
leaseTtlSec: RuntimeProfileLeaseTtlSec,
|
|
9541
9662
|
heartbeatIntervalMs: RuntimeProfileHeartbeatIntervalMs,
|
|
9542
9663
|
maxBatchSize: RuntimeProfileMaxBatchSize,
|
|
9664
|
+
maxTurns: RuntimeProfileMaxTurns,
|
|
9665
|
+
maxBashTimeouts: RuntimeProfileMaxBashTimeouts,
|
|
9543
9666
|
requiredEnv: _Array_(RuntimeProfileEnvName, { maxItems: 100 }),
|
|
9544
9667
|
requiredTools: _Array_(RuntimeProfileToolName, { maxItems: 100 }),
|
|
9545
9668
|
context: _Array_(RuntimeProfileContext, { maxItems: 5 }),
|
|
@@ -9557,6 +9680,64 @@ _Object_({
|
|
|
9557
9680
|
additionalProperties: false
|
|
9558
9681
|
});
|
|
9559
9682
|
//#endregion
|
|
9683
|
+
//#region ../tasks/src/runtime-sessions.ts
|
|
9684
|
+
var RuntimeSessionKind = Union([
|
|
9685
|
+
Literal("root"),
|
|
9686
|
+
Literal("extend"),
|
|
9687
|
+
Literal("fork")
|
|
9688
|
+
]);
|
|
9689
|
+
var RuntimeSessionCheckpointKind = Union([Literal("attempt_final")]);
|
|
9690
|
+
_Object_({
|
|
9691
|
+
id: String$1({ format: "uuid" }),
|
|
9692
|
+
teamId: String$1({ format: "uuid" }),
|
|
9693
|
+
taskId: String$1({ format: "uuid" }),
|
|
9694
|
+
attemptN: Integer({ minimum: 1 }),
|
|
9695
|
+
sourceSlotId: Union([String$1({ format: "uuid" }), Null()]),
|
|
9696
|
+
sourceRuntimeProfileId: Union([String$1({ format: "uuid" }), Null()]),
|
|
9697
|
+
sessionKind: RuntimeSessionKind,
|
|
9698
|
+
parentSessionId: Union([String$1({ format: "uuid" }), Null()]),
|
|
9699
|
+
contentType: String$1({
|
|
9700
|
+
minLength: 1,
|
|
9701
|
+
maxLength: 200
|
|
9702
|
+
}),
|
|
9703
|
+
contentEncoding: Union([String$1({
|
|
9704
|
+
minLength: 1,
|
|
9705
|
+
maxLength: 100
|
|
9706
|
+
}), Null()]),
|
|
9707
|
+
sizeBytes: Integer({ minimum: 0 }),
|
|
9708
|
+
sha256: String$1({
|
|
9709
|
+
minLength: 64,
|
|
9710
|
+
maxLength: 64
|
|
9711
|
+
}),
|
|
9712
|
+
storageClass: String$1({
|
|
9713
|
+
minLength: 1,
|
|
9714
|
+
maxLength: 100
|
|
9715
|
+
}),
|
|
9716
|
+
checkpointKind: RuntimeSessionCheckpointKind,
|
|
9717
|
+
uploadedAt: String$1({ format: "date-time" })
|
|
9718
|
+
}, { $id: "RuntimeSession" });
|
|
9719
|
+
_Object_({
|
|
9720
|
+
sourceSlotId: Optional(String$1({ format: "uuid" })),
|
|
9721
|
+
sourceRuntimeProfileId: Optional(String$1({ format: "uuid" })),
|
|
9722
|
+
sessionKind: RuntimeSessionKind,
|
|
9723
|
+
parentSessionId: Optional(String$1({ format: "uuid" }))
|
|
9724
|
+
}, {
|
|
9725
|
+
$id: "UploadRuntimeSessionQuery",
|
|
9726
|
+
additionalProperties: false
|
|
9727
|
+
});
|
|
9728
|
+
String$1({
|
|
9729
|
+
$id: "RuntimeSessionContent",
|
|
9730
|
+
description: "Runtime session content stream.",
|
|
9731
|
+
format: "binary"
|
|
9732
|
+
});
|
|
9733
|
+
_Object_({
|
|
9734
|
+
taskId: String$1({ format: "uuid" }),
|
|
9735
|
+
attemptN: Integer({ minimum: 1 })
|
|
9736
|
+
}, {
|
|
9737
|
+
$id: "RuntimeSessionAttemptParams",
|
|
9738
|
+
additionalProperties: false
|
|
9739
|
+
});
|
|
9740
|
+
//#endregion
|
|
9560
9741
|
//#region ../tasks/src/runtime-slots.ts
|
|
9561
9742
|
var RuntimeWorkspaceKind = Union([
|
|
9562
9743
|
Literal("origin"),
|
|
@@ -14645,6 +14826,7 @@ function createAgent(options) {
|
|
|
14645
14826
|
runtimeProfiles: createRuntimeProfilesNamespace(context),
|
|
14646
14827
|
tasks: createTasksNamespace(context),
|
|
14647
14828
|
runtimeSlots: createRuntimeSlotsNamespace(context),
|
|
14829
|
+
runtimeSessions: createRuntimeSessionsNamespace(context),
|
|
14648
14830
|
client,
|
|
14649
14831
|
getToken: () => tokenManager.getToken()
|
|
14650
14832
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/pi-extension",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.2",
|
|
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.30.1",
|
|
40
|
+
"@themoltnet/sdk": "0.113.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@earendil-works/pi-coding-agent": ">=0.74.0",
|