@themoltnet/agent-daemon 0.15.0 → 0.16.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.
Files changed (2) hide show
  1. package/dist/main.js +158 -20
  2. package/package.json +7 -6
package/dist/main.js CHANGED
@@ -4273,6 +4273,155 @@ var TaskContext = _Array_(_Object_({
4273
4273
  maxItems: 5
4274
4274
  });
4275
4275
  //#endregion
4276
+ //#region ../../libs/tasks/src/daemon-profiles.ts
4277
+ var DaemonProfileName = String$1({
4278
+ minLength: 1,
4279
+ maxLength: 100,
4280
+ pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$"
4281
+ });
4282
+ var DaemonProfileEnvName = String$1({
4283
+ minLength: 1,
4284
+ maxLength: 128,
4285
+ pattern: "^[A-Z_][A-Z0-9_]*$"
4286
+ });
4287
+ var DaemonProfileToolName = String$1({
4288
+ minLength: 1,
4289
+ maxLength: 128,
4290
+ pattern: "^[a-zA-Z0-9._/-]+$"
4291
+ });
4292
+ var SandboxResumeCommandWhenSchema = _Object_({ workspaceMode: Optional(_Array_(Union([
4293
+ Literal("shared_mount"),
4294
+ Literal("dedicated_worktree"),
4295
+ Literal("scratch_mount")
4296
+ ]), {
4297
+ minItems: 1,
4298
+ maxItems: 3
4299
+ })) }, { additionalProperties: false });
4300
+ var DaemonProfileSandboxResumeCommand = Union([String$1({
4301
+ minLength: 1,
4302
+ maxLength: 4096
4303
+ }), _Object_({
4304
+ run: String$1({
4305
+ minLength: 1,
4306
+ maxLength: 4096
4307
+ }),
4308
+ when: Optional(SandboxResumeCommandWhenSchema),
4309
+ retries: Optional(Integer({
4310
+ minimum: 0,
4311
+ maximum: 5
4312
+ })),
4313
+ retryBackoffMs: Optional(Integer({
4314
+ minimum: 0,
4315
+ maximum: 6e4
4316
+ }))
4317
+ }, { additionalProperties: false })]);
4318
+ var DaemonProfileSandbox = _Object_({
4319
+ snapshot: Optional(_Object_({
4320
+ setupCommands: Optional(_Array_(String$1({
4321
+ minLength: 1,
4322
+ maxLength: 4096
4323
+ }), { maxItems: 20 })),
4324
+ allowedHosts: Optional(_Array_(String$1({
4325
+ minLength: 1,
4326
+ maxLength: 255
4327
+ }), { maxItems: 50 })),
4328
+ overlaySize: Optional(String$1({
4329
+ minLength: 2,
4330
+ maxLength: 16,
4331
+ pattern: "^[0-9]+[KMGTP]?$"
4332
+ }))
4333
+ }, { additionalProperties: false })),
4334
+ resumeCommands: Optional(_Array_(DaemonProfileSandboxResumeCommand, { maxItems: 30 })),
4335
+ vfs: Optional(_Object_({
4336
+ shadow: Optional(_Array_(String$1({
4337
+ minLength: 1,
4338
+ maxLength: 255
4339
+ }), { maxItems: 100 })),
4340
+ shadowMode: Optional(Union([Literal("deny"), Literal("tmpfs")]))
4341
+ }, { additionalProperties: false })),
4342
+ env: Optional(Record(DaemonProfileEnvName, String$1({ maxLength: 4096 }))),
4343
+ hostExec: Optional(_Object_({ autoApprove: Optional(Literal(false)) }, { additionalProperties: false })),
4344
+ resources: Optional(_Object_({
4345
+ memory: Optional(String$1({
4346
+ minLength: 2,
4347
+ maxLength: 16,
4348
+ pattern: "^[0-9]+[KMG]?$"
4349
+ })),
4350
+ cpus: Optional(Integer({
4351
+ minimum: 1,
4352
+ maximum: 32
4353
+ }))
4354
+ }, { additionalProperties: false }))
4355
+ }, {
4356
+ $id: "DaemonProfileSandbox",
4357
+ additionalProperties: false
4358
+ });
4359
+ var DaemonProfileContext = _Object_({
4360
+ slug: String$1({
4361
+ minLength: 1,
4362
+ maxLength: 64,
4363
+ pattern: "^[a-zA-Z0-9_-]+$"
4364
+ }),
4365
+ binding: Union([
4366
+ Literal("skill"),
4367
+ Literal("context_inline"),
4368
+ Literal("prompt_prefix"),
4369
+ Literal("user_inline")
4370
+ ]),
4371
+ content: String$1({
4372
+ minLength: 1,
4373
+ maxLength: 65536
4374
+ })
4375
+ }, {
4376
+ $id: "DaemonProfileContext",
4377
+ additionalProperties: false
4378
+ });
4379
+ var DaemonProfileRef = _Object_({ profileId: String$1({ format: "uuid" }) }, {
4380
+ $id: "DaemonProfileRef",
4381
+ additionalProperties: false
4382
+ });
4383
+ _Object_({
4384
+ id: String$1({ format: "uuid" }),
4385
+ teamId: String$1({ format: "uuid" }),
4386
+ name: DaemonProfileName,
4387
+ description: Union([String$1({ maxLength: 4096 }), Null()]),
4388
+ provider: String$1({
4389
+ minLength: 1,
4390
+ maxLength: 100
4391
+ }),
4392
+ model: String$1({
4393
+ minLength: 1,
4394
+ maxLength: 200
4395
+ }),
4396
+ runtimeKind: Literal("gondolin_pi"),
4397
+ sandbox: DaemonProfileSandbox,
4398
+ sessionStorageMode: Literal("local"),
4399
+ workspaceStorageMode: Literal("local"),
4400
+ sessionTtlSec: Integer({
4401
+ minimum: 1,
4402
+ maximum: 86400
4403
+ }),
4404
+ workspaceTtlSec: Integer({
4405
+ minimum: 1,
4406
+ maximum: 86400
4407
+ }),
4408
+ requiredEnv: _Array_(DaemonProfileEnvName, { maxItems: 100 }),
4409
+ requiredTools: _Array_(DaemonProfileToolName, { maxItems: 100 }),
4410
+ context: _Array_(DaemonProfileContext, { maxItems: 5 }),
4411
+ revision: Integer({ minimum: 1 }),
4412
+ definitionCid: String$1({
4413
+ minLength: 1,
4414
+ maxLength: 100
4415
+ }),
4416
+ createdByAgentId: Union([String$1({ format: "uuid" }), Null()]),
4417
+ createdByHumanId: Union([String$1({ format: "uuid" }), Null()]),
4418
+ createdAt: String$1({ format: "date-time" }),
4419
+ updatedAt: String$1({ format: "date-time" })
4420
+ }, {
4421
+ $id: "DaemonProfile",
4422
+ additionalProperties: false
4423
+ });
4424
+ //#endregion
4276
4425
  //#region ../../libs/tasks/src/rubric.ts
4277
4426
  /**
4278
4427
  * Rubric — structured acceptance criteria used by judgment tasks.
@@ -8975,14 +9124,6 @@ var ExecutorTrustLevel = Union([
8975
9124
  Literal("releaseVerifiedTool"),
8976
9125
  Literal("sandboxAttested")
8977
9126
  ], { $id: "ExecutorTrustLevel" });
8978
- /** Identifies a (provider, model) daemon pair allowed to claim a task. */
8979
- var ExecutorRef = _Object_({
8980
- provider: String$1({ minLength: 1 }),
8981
- model: String$1({ minLength: 1 })
8982
- }, {
8983
- $id: "ExecutorRef",
8984
- additionalProperties: false
8985
- });
8986
9127
  var OutputKind = Union([Literal("artifact"), Literal("judgment")], { $id: "OutputKind" });
8987
9128
  var TaskMessageKind = Union([
8988
9129
  Literal("text_delta"),
@@ -9127,7 +9268,7 @@ _Object_({
9127
9268
  acceptedAttemptN: Union([Number$1(), Null()]),
9128
9269
  claimCondition: Union([Unsafe(Ref$2("ClaimCondition")), Null()]),
9129
9270
  requiredExecutorTrustLevel: ExecutorTrustLevel,
9130
- allowedExecutors: _Array_(ExecutorRef, { maxItems: 16 }),
9271
+ allowedProfiles: _Array_(DaemonProfileRef, { maxItems: 16 }),
9131
9272
  status: TaskStatus,
9132
9273
  queuedAt: IsoTimestamp,
9133
9274
  completedAt: Union([IsoTimestamp, Null()]),
@@ -30908,7 +31049,6 @@ var PollingApiTaskSource = class {
30908
31049
  this.minBackoffMs = opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
30909
31050
  this.maxBackoffMs = opts.maxPollIntervalMs ?? DEFAULT_MAX_POLL_INTERVAL_MS;
30910
31051
  if (this.maxBackoffMs < this.minBackoffMs) throw new Error(`PollingApiTaskSource: maxPollIntervalMs (${this.maxBackoffMs}) must be >= pollIntervalMs (${this.minBackoffMs})`);
30911
- if (Boolean(opts.provider) !== Boolean(opts.model)) throw new Error("PollingApiTaskSource: provider and model must be set together");
30912
31052
  this.listLimit = opts.listLimit ?? DEFAULT_LIST_LIMIT;
30913
31053
  this.currentBackoffMs = this.minBackoffMs;
30914
31054
  this.logger = (opts.logger ?? pino({ name: "polling-api-source" })).child({ teamId: opts.teamId });
@@ -30951,10 +31091,7 @@ var PollingApiTaskSource = class {
30951
31091
  teamId: this.opts.teamId,
30952
31092
  status: "queued",
30953
31093
  ...taskTypes ? { taskTypes } : {},
30954
- ...this.opts.provider && this.opts.model ? {
30955
- provider: this.opts.provider,
30956
- model: this.opts.model
30957
- } : {},
31094
+ ...this.opts.profileId ? { profileId: this.opts.profileId } : {},
30958
31095
  ...cursor ? { cursor } : {},
30959
31096
  limit: this.listLimit
30960
31097
  });
@@ -30969,9 +31106,9 @@ var PollingApiTaskSource = class {
30969
31106
  if (this.opts.taskTypes && this.opts.taskTypes.length > 0 && !this.opts.taskTypes.includes(item.taskType)) continue;
30970
31107
  if (this.opts.diaryIds && this.opts.diaryIds.length > 0 && (item.diaryId === null || !this.opts.diaryIds.includes(item.diaryId))) continue;
30971
31108
  if (this.opts.slotRegistry && !await isContinuationClaimableByThisDaemon(item, this.opts.slotRegistry)) continue;
30972
- if (this.opts.provider && this.opts.model) {
30973
- const allowed = item.allowedExecutors ?? [];
30974
- if (allowed.length > 0 && !allowed.some((e) => e.provider === this.opts.provider && e.model === this.opts.model)) continue;
31109
+ if (this.opts.profileId) {
31110
+ const allowed = item.allowedProfiles ?? [];
31111
+ if (allowed.length > 0 && !allowed.some((p) => p.profileId === this.opts.profileId)) continue;
30975
31112
  }
30976
31113
  if (item.status !== "queued") continue;
30977
31114
  seen.add(item.id);
@@ -30994,7 +31131,10 @@ var PollingApiTaskSource = class {
30994
31131
  for (const task of candidates) {
30995
31132
  if (this.aborted()) return null;
30996
31133
  try {
30997
- const result = await this.opts.agent.tasks.claim(task.id, { leaseTtlSec: this.opts.leaseTtlSec });
31134
+ const result = await this.opts.agent.tasks.claim(task.id, {
31135
+ leaseTtlSec: this.opts.leaseTtlSec,
31136
+ ...this.opts.profileId ? { profileId: this.opts.profileId } : {}
31137
+ });
30998
31138
  if (this.opts.debug) this.logger.debug({
30999
31139
  taskId: result.task.id,
31000
31140
  taskType: result.task.taskType,
@@ -35023,8 +35163,6 @@ async function runPolling(opts) {
35023
35163
  agent: ctx.agent,
35024
35164
  teamId,
35025
35165
  taskTypes: taskTypes.length > 0 ? taskTypes : void 0,
35026
- provider: common.provider.toLowerCase(),
35027
- model: common.model.toLowerCase(),
35028
35166
  diaryIds: diaryIds.length > 0 ? diaryIds : void 0,
35029
35167
  leaseTtlSec: common.leaseTtlSec,
35030
35168
  listLimit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/agent-daemon",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "description": "MoltNet agent daemon — claims and executes tasks (fulfill_brief, assess_brief) from the MoltNet task-service via Pi-headless. CLI: moltnet-agent.",
@@ -45,19 +45,20 @@
45
45
  "pino": "^10.3.1",
46
46
  "pino-pretty": "^13.1.3",
47
47
  "@themoltnet/agent-daemon-state": "0.2.0",
48
- "@themoltnet/agent-runtime": "0.22.4",
49
- "@themoltnet/sdk": "0.106.0",
50
- "@themoltnet/pi-extension": "0.22.5"
48
+ "@themoltnet/pi-extension": "0.23.0",
49
+ "@themoltnet/sdk": "0.107.0",
50
+ "@themoltnet/agent-runtime": "0.23.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "tsx": "^4.7.0",
54
54
  "typescript": "~5.9.2",
55
55
  "vite": "^8.0.0",
56
56
  "vitest": "^3.0.0",
57
- "@moltnet/bootstrap": "0.1.0",
57
+ "@moltnet/api-client": "0.1.0",
58
58
  "@moltnet/crypto-service": "0.1.0",
59
+ "@moltnet/observability": "0.1.0",
59
60
  "@moltnet/tasks": "0.1.0",
60
- "@moltnet/observability": "0.1.0"
61
+ "@moltnet/bootstrap": "0.1.0"
61
62
  },
62
63
  "nx": {
63
64
  "tags": [