@themoltnet/pi-extension 0.35.0 → 0.35.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 +190 -31
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -658,6 +658,102 @@ var getNetworkInfo = (options) => (options?.client ?? client).get({
|
|
|
658
658
|
...options
|
|
659
659
|
});
|
|
660
660
|
/**
|
|
661
|
+
* List agent API keys bound to the active team. Team credential managers may list every agent.
|
|
662
|
+
*/
|
|
663
|
+
var listAgentKeys = (options) => (options.client ?? client).get({
|
|
664
|
+
security: [
|
|
665
|
+
{
|
|
666
|
+
scheme: "bearer",
|
|
667
|
+
type: "http"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
name: "X-Moltnet-Session-Token",
|
|
671
|
+
type: "apiKey"
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
in: "cookie",
|
|
675
|
+
name: "ory_kratos_session",
|
|
676
|
+
type: "apiKey"
|
|
677
|
+
}
|
|
678
|
+
],
|
|
679
|
+
url: "/agent-keys",
|
|
680
|
+
...options
|
|
681
|
+
});
|
|
682
|
+
/**
|
|
683
|
+
* Issue a secret API key bound to one agent and the active team.
|
|
684
|
+
*/
|
|
685
|
+
var createAgentKey = (options) => (options.client ?? client).post({
|
|
686
|
+
security: [
|
|
687
|
+
{
|
|
688
|
+
scheme: "bearer",
|
|
689
|
+
type: "http"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
name: "X-Moltnet-Session-Token",
|
|
693
|
+
type: "apiKey"
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
in: "cookie",
|
|
697
|
+
name: "ory_kratos_session",
|
|
698
|
+
type: "apiKey"
|
|
699
|
+
}
|
|
700
|
+
],
|
|
701
|
+
url: "/agent-keys",
|
|
702
|
+
...options,
|
|
703
|
+
headers: {
|
|
704
|
+
"Content-Type": "application/json",
|
|
705
|
+
...options.headers
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
/**
|
|
709
|
+
* Permanently revoke an agent API key.
|
|
710
|
+
*/
|
|
711
|
+
var revokeAgentKey = (options) => (options.client ?? client).post({
|
|
712
|
+
security: [
|
|
713
|
+
{
|
|
714
|
+
scheme: "bearer",
|
|
715
|
+
type: "http"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
name: "X-Moltnet-Session-Token",
|
|
719
|
+
type: "apiKey"
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
in: "cookie",
|
|
723
|
+
name: "ory_kratos_session",
|
|
724
|
+
type: "apiKey"
|
|
725
|
+
}
|
|
726
|
+
],
|
|
727
|
+
url: "/agent-keys/{keyId}/revoke",
|
|
728
|
+
...options,
|
|
729
|
+
headers: {
|
|
730
|
+
"Content-Type": "application/json",
|
|
731
|
+
...options.headers
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
/**
|
|
735
|
+
* Rotate an agent API key immediately. The previous secret is revoked and expiry is unchanged.
|
|
736
|
+
*/
|
|
737
|
+
var rotateAgentKey = (options) => (options.client ?? client).post({
|
|
738
|
+
security: [
|
|
739
|
+
{
|
|
740
|
+
scheme: "bearer",
|
|
741
|
+
type: "http"
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: "X-Moltnet-Session-Token",
|
|
745
|
+
type: "apiKey"
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
in: "cookie",
|
|
749
|
+
name: "ory_kratos_session",
|
|
750
|
+
type: "apiKey"
|
|
751
|
+
}
|
|
752
|
+
],
|
|
753
|
+
url: "/agent-keys/{keyId}/rotate",
|
|
754
|
+
...options
|
|
755
|
+
});
|
|
756
|
+
/**
|
|
661
757
|
* Get the authenticated agent identity (requires bearer token).
|
|
662
758
|
*/
|
|
663
759
|
var getWhoami = (options) => (options?.client ?? client).get({
|
|
@@ -2941,6 +3037,82 @@ function unwrapRequired(result, message, code) {
|
|
|
2941
3037
|
return result.data;
|
|
2942
3038
|
}
|
|
2943
3039
|
//#endregion
|
|
3040
|
+
//#region ../sdk/src/namespaces/query.ts
|
|
3041
|
+
/**
|
|
3042
|
+
* Remove `undefined`-valued keys from a query object before it is serialized.
|
|
3043
|
+
*
|
|
3044
|
+
* Returns `undefined` when no defined keys remain, so an all-`undefined` query
|
|
3045
|
+
* (`{ agentId: undefined }`) and an omitted query (`undefined`) serialize
|
|
3046
|
+
* identically — both send no query params — instead of the former collapsing to
|
|
3047
|
+
* an empty `{}` that still reaches the client.
|
|
3048
|
+
*/
|
|
3049
|
+
function stripUndefinedQuery(query) {
|
|
3050
|
+
if (!query) return;
|
|
3051
|
+
const entries = Object.entries(query).filter(([, value]) => value !== void 0);
|
|
3052
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3053
|
+
}
|
|
3054
|
+
//#endregion
|
|
3055
|
+
//#region ../sdk/src/namespaces/team-headers.ts
|
|
3056
|
+
/**
|
|
3057
|
+
* Build the team header from an optional option, or `undefined` when no team
|
|
3058
|
+
* context was supplied. Used by diaries and runtime-profiles, whose endpoints
|
|
3059
|
+
* accept the header optionally.
|
|
3060
|
+
*/
|
|
3061
|
+
function teamHeaders(options) {
|
|
3062
|
+
return options?.teamId ? { "x-moltnet-team-id": options.teamId } : void 0;
|
|
3063
|
+
}
|
|
3064
|
+
/**
|
|
3065
|
+
* Build the team header from a required option. Used by tasks and
|
|
3066
|
+
* runtime-slots, whose endpoints mandate the header.
|
|
3067
|
+
*/
|
|
3068
|
+
function requiredTeamHeaders(options) {
|
|
3069
|
+
return { "x-moltnet-team-id": options.teamId };
|
|
3070
|
+
}
|
|
3071
|
+
//#endregion
|
|
3072
|
+
//#region ../sdk/src/namespaces/agent-keys.ts
|
|
3073
|
+
function createAgentKeysNamespace(context) {
|
|
3074
|
+
const { client, auth } = context;
|
|
3075
|
+
return {
|
|
3076
|
+
async list(query, options) {
|
|
3077
|
+
return unwrapResult(await listAgentKeys({
|
|
3078
|
+
client,
|
|
3079
|
+
auth,
|
|
3080
|
+
headers: requiredTeamHeaders(options),
|
|
3081
|
+
query: stripUndefinedQuery(query)
|
|
3082
|
+
}));
|
|
3083
|
+
},
|
|
3084
|
+
async create(body, options) {
|
|
3085
|
+
return unwrapResult(await createAgentKey({
|
|
3086
|
+
client,
|
|
3087
|
+
auth,
|
|
3088
|
+
headers: {
|
|
3089
|
+
...requiredTeamHeaders(options),
|
|
3090
|
+
"idempotency-key": options.idempotencyKey
|
|
3091
|
+
},
|
|
3092
|
+
body
|
|
3093
|
+
}));
|
|
3094
|
+
},
|
|
3095
|
+
async rotate(keyId, options) {
|
|
3096
|
+
return unwrapResult(await rotateAgentKey({
|
|
3097
|
+
client,
|
|
3098
|
+
auth,
|
|
3099
|
+
headers: requiredTeamHeaders(options),
|
|
3100
|
+
path: { keyId }
|
|
3101
|
+
}));
|
|
3102
|
+
},
|
|
3103
|
+
async revoke(keyId, body, options) {
|
|
3104
|
+
const result = await revokeAgentKey({
|
|
3105
|
+
client,
|
|
3106
|
+
auth,
|
|
3107
|
+
headers: requiredTeamHeaders(options),
|
|
3108
|
+
path: { keyId },
|
|
3109
|
+
body
|
|
3110
|
+
});
|
|
3111
|
+
if (result.error) unwrapResult(result);
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
//#endregion
|
|
2944
3116
|
//#region ../sdk/src/namespaces/agents.ts
|
|
2945
3117
|
function createAgentsNamespace(context) {
|
|
2946
3118
|
const { client, auth } = context;
|
|
@@ -2998,23 +3170,6 @@ function createCryptoNamespace(context, signingRequests) {
|
|
|
2998
3170
|
};
|
|
2999
3171
|
}
|
|
3000
3172
|
//#endregion
|
|
3001
|
-
//#region ../sdk/src/namespaces/team-headers.ts
|
|
3002
|
-
/**
|
|
3003
|
-
* Build the team header from an optional option, or `undefined` when no team
|
|
3004
|
-
* context was supplied. Used by diaries and runtime-profiles, whose endpoints
|
|
3005
|
-
* accept the header optionally.
|
|
3006
|
-
*/
|
|
3007
|
-
function teamHeaders(options) {
|
|
3008
|
-
return options?.teamId ? { "x-moltnet-team-id": options.teamId } : void 0;
|
|
3009
|
-
}
|
|
3010
|
-
/**
|
|
3011
|
-
* Build the team header from a required option. Used by tasks and
|
|
3012
|
-
* runtime-slots, whose endpoints mandate the header.
|
|
3013
|
-
*/
|
|
3014
|
-
function requiredTeamHeaders(options) {
|
|
3015
|
-
return { "x-moltnet-team-id": options.teamId };
|
|
3016
|
-
}
|
|
3017
|
-
//#endregion
|
|
3018
3173
|
//#region ../sdk/src/namespaces/diaries.ts
|
|
3019
3174
|
function createDiariesNamespace(context) {
|
|
3020
3175
|
const { client, auth } = context;
|
|
@@ -4925,7 +5080,10 @@ function createEntriesNamespace(context) {
|
|
|
4925
5080
|
const signingRequest = unwrapResult(await createSigningRequest({
|
|
4926
5081
|
client,
|
|
4927
5082
|
auth,
|
|
4928
|
-
body: {
|
|
5083
|
+
body: {
|
|
5084
|
+
message: computeContentCid(body.entryType ?? "semantic", body.title ?? null, body.content, body.tags ?? null),
|
|
5085
|
+
verificationMethod: "agent-ed25519"
|
|
5086
|
+
}
|
|
4929
5087
|
}));
|
|
4930
5088
|
const privateKeyBytes = new Uint8Array(Buffer.from(privateKey, "base64"));
|
|
4931
5089
|
const signature = await signAsync(new Uint8Array(Buffer.from(signingRequest.signingInput, "base64")), privateKeyBytes);
|
|
@@ -5290,12 +5448,11 @@ function createRuntimeSlotsNamespace(context) {
|
|
|
5290
5448
|
}
|
|
5291
5449
|
},
|
|
5292
5450
|
async list(query, options) {
|
|
5293
|
-
const filteredQuery = Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0));
|
|
5294
5451
|
return unwrapResult(await listRuntimeSlots({
|
|
5295
5452
|
auth,
|
|
5296
5453
|
client,
|
|
5297
5454
|
headers: requiredTeamHeaders(options),
|
|
5298
|
-
query:
|
|
5455
|
+
query: stripUndefinedQuery(query)
|
|
5299
5456
|
})).items;
|
|
5300
5457
|
}
|
|
5301
5458
|
};
|
|
@@ -15585,8 +15742,10 @@ function createAgent(options) {
|
|
|
15585
15742
|
client,
|
|
15586
15743
|
auth
|
|
15587
15744
|
};
|
|
15745
|
+
const diaries = createDiariesNamespace(context);
|
|
15588
15746
|
return {
|
|
15589
|
-
|
|
15747
|
+
agentKeys: createAgentKeysNamespace(context),
|
|
15748
|
+
diaries,
|
|
15590
15749
|
diaryGrants: createDiaryGrantsNamespace(context),
|
|
15591
15750
|
diaryTransfers: createDiaryTransfersNamespace(context),
|
|
15592
15751
|
packs: createPacksNamespace(context),
|
|
@@ -26456,20 +26615,20 @@ async function openVmWorkspaceFileForRead(config) {
|
|
|
26456
26615
|
};
|
|
26457
26616
|
}
|
|
26458
26617
|
function createGondolinToolDefinitions(config) {
|
|
26459
|
-
const { vm,
|
|
26460
|
-
const grepTool = createGrepToolDefinition(
|
|
26618
|
+
const { vm, cwdPath, guestWorkspace } = config;
|
|
26619
|
+
const grepTool = createGrepToolDefinition(cwdPath);
|
|
26461
26620
|
return [
|
|
26462
|
-
createReadToolDefinition(
|
|
26463
|
-
createWriteToolDefinition(
|
|
26464
|
-
createEditToolDefinition(
|
|
26465
|
-
createBashToolDefinition(
|
|
26466
|
-
createLsToolDefinition(
|
|
26467
|
-
createFindToolDefinition(
|
|
26621
|
+
createReadToolDefinition(cwdPath, { operations: createGondolinReadOps(vm, cwdPath, guestWorkspace) }),
|
|
26622
|
+
createWriteToolDefinition(cwdPath, { operations: createGondolinWriteOps(vm, cwdPath, guestWorkspace) }),
|
|
26623
|
+
createEditToolDefinition(cwdPath, { operations: createGondolinEditOps(vm, cwdPath, guestWorkspace) }),
|
|
26624
|
+
createBashToolDefinition(cwdPath, { operations: createGondolinBashOps(vm, cwdPath, guestWorkspace) }),
|
|
26625
|
+
createLsToolDefinition(cwdPath, { operations: createGondolinLsOps(vm, cwdPath, guestWorkspace) }),
|
|
26626
|
+
createFindToolDefinition(cwdPath, { operations: createGondolinFindOps(vm, cwdPath, guestWorkspace) }),
|
|
26468
26627
|
{
|
|
26469
26628
|
...grepTool,
|
|
26470
26629
|
async execute(...args) {
|
|
26471
26630
|
const [_id, params, signal] = args;
|
|
26472
|
-
return executeGondolinGrep(vm,
|
|
26631
|
+
return executeGondolinGrep(vm, cwdPath, guestWorkspace, params, signal);
|
|
26473
26632
|
}
|
|
26474
26633
|
}
|
|
26475
26634
|
];
|
|
@@ -26759,7 +26918,7 @@ async function executePiTask(claimedTask, reporter, opts) {
|
|
|
26759
26918
|
if (injectedContext.userInlineSuffix) taskPrompt = `${taskPrompt}\n\n---\n\n${injectedContext.userInlineSuffix}`;
|
|
26760
26919
|
const gondolinCustomTools = createGondolinToolDefinitions({
|
|
26761
26920
|
vm: managed.vm,
|
|
26762
|
-
|
|
26921
|
+
cwdPath,
|
|
26763
26922
|
guestWorkspace: managed.guestWorkspace
|
|
26764
26923
|
});
|
|
26765
26924
|
const { handle: submitToolHandle, tools: submitToolDefs } = resolveSubmitTools(task.taskType, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/pi-extension",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.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/
|
|
40
|
-
"@themoltnet/
|
|
39
|
+
"@themoltnet/agent-runtime": "0.36.2",
|
|
40
|
+
"@themoltnet/sdk": "0.123.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@earendil-works/pi-coding-agent": ">=0.74.0",
|