@primusclaw/personal-agent-runtime 0.8.1 → 0.9.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.js +100 -6
- package/dist/types/claw/skills.d.ts +16 -0
- package/dist/types/worker/features-w8.d.ts +3 -1
- package/dist/worker.js +11 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1225,6 +1225,99 @@ function isObject4(value) {
|
|
|
1225
1225
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1226
1226
|
}
|
|
1227
1227
|
|
|
1228
|
+
// packages/runtime/src/claw/skills.ts
|
|
1229
|
+
import {
|
|
1230
|
+
ClawAnswerInvalid as ClawAnswerInvalid9,
|
|
1231
|
+
pyStr as pyStr4
|
|
1232
|
+
} from "@primusclaw/personal-agent";
|
|
1233
|
+
function int(value) {
|
|
1234
|
+
return typeof value === "number" && Number.isSafeInteger(value) ? value : null;
|
|
1235
|
+
}
|
|
1236
|
+
function entryOf(row) {
|
|
1237
|
+
const name = pyStr4(row["name"]);
|
|
1238
|
+
if (!name) throw new ClawAnswerInvalid9("a skill without its name");
|
|
1239
|
+
return {
|
|
1240
|
+
name,
|
|
1241
|
+
version: int(row["version"]) ?? 0,
|
|
1242
|
+
description: pyStr4(row["description"]),
|
|
1243
|
+
enabled: row["enabled"] !== false,
|
|
1244
|
+
invocation: row["invocation"] === "manual" ? "manual" : "auto",
|
|
1245
|
+
imported: row["origin"] === "import",
|
|
1246
|
+
lastUsedAt: pyStr4(row["last_used_at"]),
|
|
1247
|
+
files: int(row["files"]) ?? 0
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
function changeOf(answer2, what) {
|
|
1251
|
+
const out = objectOf(answer2, what);
|
|
1252
|
+
return {
|
|
1253
|
+
version: int(out["version"]),
|
|
1254
|
+
changed: out["changed"] !== false,
|
|
1255
|
+
changeId: pyStr4(out["change_id"]),
|
|
1256
|
+
undoExpiresAt: pyStr4(out["undo_expires_at"])
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
var HttpSkills = class {
|
|
1260
|
+
constructor(http) {
|
|
1261
|
+
this.http = http;
|
|
1262
|
+
}
|
|
1263
|
+
http;
|
|
1264
|
+
async list(key2) {
|
|
1265
|
+
const answer2 = await this.http.json({ method: "GET", path: "/v1/users/me/skills?view=current", key: key2 });
|
|
1266
|
+
return rowsOf(answer2, "the skills").map(entryOf);
|
|
1267
|
+
}
|
|
1268
|
+
async show(key2, name) {
|
|
1269
|
+
const answer2 = await this.http.json({
|
|
1270
|
+
method: "GET",
|
|
1271
|
+
path: `/v1/users/me/skills/${segment(name)}?view=current`,
|
|
1272
|
+
key: key2
|
|
1273
|
+
});
|
|
1274
|
+
const data = dataOf(answer2, "a skill");
|
|
1275
|
+
const files = Array.isArray(data["file_list"]) ? data["file_list"] : [];
|
|
1276
|
+
return {
|
|
1277
|
+
...entryOf(data),
|
|
1278
|
+
content: pyStr4(data["content"]),
|
|
1279
|
+
fileList: files.flatMap(
|
|
1280
|
+
(f) => typeof f === "object" && f !== null && typeof f["path"] === "string" ? [
|
|
1281
|
+
{
|
|
1282
|
+
path: pyStr4(f["path"]),
|
|
1283
|
+
sizeBytes: int(f["size_bytes"]) ?? 0
|
|
1284
|
+
}
|
|
1285
|
+
] : []
|
|
1286
|
+
)
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
async setEnabled(key2, name, enabled) {
|
|
1290
|
+
const verb = enabled ? "enable" : "disable";
|
|
1291
|
+
return changeOf(
|
|
1292
|
+
await this.http.json({ method: "POST", path: `/v1/users/me/skills/${segment(name)}/${verb}`, key: key2, body: {} }),
|
|
1293
|
+
"a switch"
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1296
|
+
async remove(key2, name) {
|
|
1297
|
+
return changeOf(
|
|
1298
|
+
await this.http.json({ method: "DELETE", path: `/v1/users/me/skills/${segment(name)}`, key: key2 }),
|
|
1299
|
+
"a delete"
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
async update(key2, name, skill) {
|
|
1303
|
+
const body = { content: skill.content, description: skill.description };
|
|
1304
|
+
return changeOf(
|
|
1305
|
+
await this.http.json({ method: "PUT", path: `/v1/users/me/skills/${segment(name)}`, key: key2, body }),
|
|
1306
|
+
"an edit"
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
async undo(key2, changeId) {
|
|
1310
|
+
const answer2 = await this.http.json({
|
|
1311
|
+
method: "POST",
|
|
1312
|
+
path: `/v1/users/me/skill-changes/${segment(changeId)}/undo`,
|
|
1313
|
+
key: key2,
|
|
1314
|
+
body: {}
|
|
1315
|
+
});
|
|
1316
|
+
const data = dataOf(answer2, "an undo");
|
|
1317
|
+
return { undone: pyStr4(data["undone"]), name: pyStr4(data["name"]), version: int(data["version"]) };
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1228
1321
|
// packages/runtime/src/claw/client.ts
|
|
1229
1322
|
var DEFAULT_CLIENT_LABEL = "clawy";
|
|
1230
1323
|
function createClawClient(options) {
|
|
@@ -1240,7 +1333,8 @@ function createClawClient(options) {
|
|
|
1240
1333
|
notifications: new HttpNotifications(http),
|
|
1241
1334
|
triggers: new HttpTriggers(http),
|
|
1242
1335
|
mergeConfirmations: new HttpMergeConfirmations(http),
|
|
1243
|
-
remoteAgents: new HttpRemoteAgents(http, options.clientLabel ?? DEFAULT_CLIENT_LABEL)
|
|
1336
|
+
remoteAgents: new HttpRemoteAgents(http, options.clientLabel ?? DEFAULT_CLIENT_LABEL),
|
|
1337
|
+
skills: new HttpSkills(http)
|
|
1244
1338
|
};
|
|
1245
1339
|
}
|
|
1246
1340
|
|
|
@@ -4305,7 +4399,7 @@ var SqliteHeldEventRepository = class {
|
|
|
4305
4399
|
db.durably(
|
|
4306
4400
|
() => db.run(
|
|
4307
4401
|
"INSERT OR IGNORE INTO held_events (event_id, aad_id, event_json, held_at) VALUES (?, ?, ?, ?)",
|
|
4308
|
-
|
|
4402
|
+
pyStr5(event["event_id"]),
|
|
4309
4403
|
userId,
|
|
4310
4404
|
pyJsonDumps(event),
|
|
4311
4405
|
now
|
|
@@ -4330,7 +4424,7 @@ var SqliteHeldEventRepository = class {
|
|
|
4330
4424
|
return rows.map((r) => storedObject(col.str(r, "event_json"))).filter((e) => e !== null);
|
|
4331
4425
|
}
|
|
4332
4426
|
};
|
|
4333
|
-
function
|
|
4427
|
+
function pyStr5(value) {
|
|
4334
4428
|
if (typeof value === "string") return value;
|
|
4335
4429
|
if (value === void 0) throw new RangeError("a held event needs an event_id");
|
|
4336
4430
|
if (value === null) return "None";
|
|
@@ -5479,13 +5573,13 @@ var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
|
5479
5573
|
var DEVICE_PAGE_HOST = "github.com";
|
|
5480
5574
|
var SLOW_DOWN_SECONDS = 5;
|
|
5481
5575
|
var MAX_DEVICE_WAIT_SECONDS = 15 * 60;
|
|
5482
|
-
var
|
|
5576
|
+
var int2 = z6.number().int().positive();
|
|
5483
5577
|
var started = z6.object({
|
|
5484
5578
|
device_code: z6.string().min(1),
|
|
5485
5579
|
user_code: z6.string().min(1),
|
|
5486
5580
|
verification_uri: z6.string(),
|
|
5487
|
-
expires_in:
|
|
5488
|
-
interval:
|
|
5581
|
+
expires_in: int2,
|
|
5582
|
+
interval: int2.optional().default(5)
|
|
5489
5583
|
});
|
|
5490
5584
|
var polled = z6.object({
|
|
5491
5585
|
error: z6.unknown().optional(),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ClawCredential, type ClawSkill, type ClawSkillChange, type ClawSkillEntry, type ClawSkillsPort, type ClawSkillUndone } from "@primusclaw/personal-agent";
|
|
2
|
+
import { type ClawHttp } from "./http.js";
|
|
3
|
+
/** `ClawSkillsPort` over Claw's HTTP API: the person's own skills, always as them. */
|
|
4
|
+
export declare class HttpSkills implements ClawSkillsPort {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: ClawHttp);
|
|
7
|
+
list(key: ClawCredential): Promise<ClawSkillEntry[]>;
|
|
8
|
+
show(key: ClawCredential, name: string): Promise<ClawSkill>;
|
|
9
|
+
setEnabled(key: ClawCredential, name: string, enabled: boolean): Promise<ClawSkillChange>;
|
|
10
|
+
remove(key: ClawCredential, name: string): Promise<ClawSkillChange>;
|
|
11
|
+
update(key: ClawCredential, name: string, skill: {
|
|
12
|
+
readonly content: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
}): Promise<ClawSkillChange>;
|
|
15
|
+
undo(key: ClawCredential, changeId: string): Promise<ClawSkillUndone>;
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonObject, OutMessage } from "@primusclaw/personal-agent";
|
|
2
|
-
import { DailyBrief, FeedbackFlow, FeedbackService, FeedbackThumbs, GroupContext, Observer } from "@primusclaw/personal-agent";
|
|
2
|
+
import { DailyBrief, SkillsCommand, FeedbackFlow, FeedbackService, FeedbackThumbs, GroupContext, Observer } from "@primusclaw/personal-agent";
|
|
3
3
|
import type { AssemblyBase } from "./features-base.js";
|
|
4
4
|
/** The brief Claw put together, as a message (Python `render.brief_markdown`). */
|
|
5
5
|
export declare function briefMarkdown(brief: JsonObject): string;
|
|
@@ -11,6 +11,8 @@ export interface W8Parts {
|
|
|
11
11
|
/** The recent messages of group chats, in memory, as background for an @mention. */
|
|
12
12
|
readonly groupContext: GroupContext;
|
|
13
13
|
readonly brief: DailyBrief;
|
|
14
|
+
/** Its commands: `/brief`, and `/skills` (the person's own skills, in their own chat). */
|
|
15
|
+
readonly commands: readonly [DailyBrief, SkillsCommand];
|
|
14
16
|
/** The Report a problem card under a message of the person's that went wrong. */
|
|
15
17
|
reportView(userId: string, scope: string): OutMessage;
|
|
16
18
|
}
|
package/dist/worker.js
CHANGED
|
@@ -90,6 +90,7 @@ import {
|
|
|
90
90
|
turn as turn2,
|
|
91
91
|
WatchClicks,
|
|
92
92
|
WorkCardClicks,
|
|
93
|
+
SkillCardClicks,
|
|
93
94
|
WorkClicks
|
|
94
95
|
} from "@primusclaw/personal-agent";
|
|
95
96
|
|
|
@@ -351,7 +352,13 @@ function assistantParts(base, inputs) {
|
|
|
351
352
|
const watch = new WatchClicks({ store, claw: claw.workItems, exchange, logger });
|
|
352
353
|
const linked = (userId) => store.links.getKey(userId) !== null;
|
|
353
354
|
const choices = new AssistantChoiceClicks({ store, deliver: (message) => hooks.typed(message), logger });
|
|
354
|
-
const
|
|
355
|
+
const skillCards = new SkillCardClicks({ store, skills: claw.skills, logger });
|
|
356
|
+
const clicks = [
|
|
357
|
+
new WorkCardClicks(work, watch, exchange, linked, logger),
|
|
358
|
+
actionClicks(actions),
|
|
359
|
+
choices,
|
|
360
|
+
skillCards
|
|
361
|
+
];
|
|
355
362
|
return { subs, chat: assistant, board, receipts, directChat, actions, clicks };
|
|
356
363
|
}
|
|
357
364
|
|
|
@@ -806,6 +813,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
806
813
|
import {
|
|
807
814
|
chatCredentialOf,
|
|
808
815
|
DailyBrief,
|
|
816
|
+
SkillsCommand,
|
|
809
817
|
FeedbackFlow,
|
|
810
818
|
FeedbackReporting,
|
|
811
819
|
FeedbackService,
|
|
@@ -932,6 +940,7 @@ function w8Parts(base, options) {
|
|
|
932
940
|
observer,
|
|
933
941
|
groupContext,
|
|
934
942
|
brief,
|
|
943
|
+
commands: [brief, new SkillsCommand({ store, skills: claw.skills, logger })],
|
|
935
944
|
reportView: (userId, scope) => {
|
|
936
945
|
const view = service.reportView(userId, scope);
|
|
937
946
|
return reportMessage(view.promptId, view.group);
|
|
@@ -1196,7 +1205,7 @@ function buildFeatures(given) {
|
|
|
1196
1205
|
personalInterceptors: [...reviewHandlers?.personalInterceptors ?? [], w8.flow.interceptor],
|
|
1197
1206
|
groupInterceptors,
|
|
1198
1207
|
commands: [
|
|
1199
|
-
w8.
|
|
1208
|
+
...w8.commands,
|
|
1200
1209
|
...switches.remoteAgents ? [new TerminalApprovalsCommand(base.claw.remoteAgents)] : [],
|
|
1201
1210
|
...reviewHandlers?.commands ?? []
|
|
1202
1211
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Node adapters for the personal agent's ports (clock, randomness, logging, storage, Claw, metrics, HTTP), and, at @primusclaw/personal-agent-runtime/worker, the worker process on any chat surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@primusclaw/personal-agent": "0.
|
|
36
|
+
"@primusclaw/personal-agent": "0.9.0",
|
|
37
37
|
"fastify": "^5.12.8",
|
|
38
38
|
"zod": "^4.6.7"
|
|
39
39
|
}
|