@north-light/cli 0.3.746 → 0.3.748

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 (70) hide show
  1. package/dist/api/contract.d.ts +1 -1
  2. package/dist/api/contract.js +1 -1
  3. package/dist/api/dto/objects.d.ts +6 -1
  4. package/dist/api/dto/plugins.d.ts +2 -0
  5. package/dist/commands/canvas/list.js +2 -2
  6. package/dist/commands/canvas/read.js +4 -4
  7. package/dist/commands/canvas/search.js +1 -1
  8. package/dist/core/canvas/canvas.js +1 -1
  9. package/dist/core/canvas/schema-pg/035-environment-payer.sql +2 -0
  10. package/dist/core/canvas/schema-version.d.ts +1 -1
  11. package/dist/core/canvas/schema-version.js +1 -1
  12. package/dist/core/command-manifests/registry.d.ts +2 -1
  13. package/dist/core/command-plugins/compose.js +1 -1
  14. package/dist/core/command.d.ts +11 -0
  15. package/dist/core/command.js +9 -9
  16. package/dist/core/environments.d.ts +2 -1
  17. package/dist/core/environments.js +1 -1
  18. package/dist/core/grants/mirror.d.ts +4 -0
  19. package/dist/core/grants/mirror.js +8 -6
  20. package/dist/core/grants/on-sync.js +1 -1
  21. package/dist/core/ledger/environment-payer.d.ts +2 -0
  22. package/dist/core/ledger/environment-payer.js +1 -0
  23. package/dist/core/ledger/index.d.ts +1 -0
  24. package/dist/core/ledger/index.js +1 -1
  25. package/dist/core/ledger/payer.d.ts +4 -1
  26. package/dist/core/ledger/payer.js +1 -1
  27. package/dist/core/llm/run.d.ts +1 -0
  28. package/dist/core/llm/run.js +2 -2
  29. package/dist/core/permissions/evaluator.js +2 -2
  30. package/dist/core/providers/call.js +1 -1
  31. package/dist/core/runs/node-sub.d.ts +2 -0
  32. package/dist/core/runs/node-sub.js +1 -0
  33. package/dist/core/runtime/host.js +3 -3
  34. package/dist/core/runtime/spawn.js +2 -2
  35. package/dist/core/runtime/start-check.d.ts +1 -0
  36. package/dist/core/runtime/start-check.js +1 -1
  37. package/dist/core/runtime/warm-pool.js +1 -1
  38. package/dist/core/spaces/process.js +1 -1
  39. package/dist/daemon/api/handlers/bash-jobs.js +2 -2
  40. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  41. package/dist/daemon/api/handlers/llm.js +3 -3
  42. package/package.json +3 -3
  43. package/packages/crouter-api/dist/api/contract.js +1 -1
  44. package/packages/crouter-api/dist/commands/canvas/list.js +3 -1
  45. package/packages/crouter-api/dist/commands/canvas/read.js +4 -2
  46. package/packages/crouter-api/dist/commands/canvas/search.js +3 -1
  47. package/packages/crouter-api/dist/core/canvas/canvas.js +1 -1
  48. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  49. package/packages/crouter-api/dist/core/command-plugins/compose.js +5 -3
  50. package/packages/crouter-api/dist/core/command.js +33 -1
  51. package/packages/crouter-api/dist/core/environments.js +2 -2
  52. package/packages/crouter-api/dist/core/grants/mirror.js +16 -1
  53. package/packages/crouter-api/dist/core/grants/on-sync.js +2 -2
  54. package/packages/crouter-api/dist/core/ledger/environment-payer.js +15 -0
  55. package/packages/crouter-api/dist/core/ledger/index.js +1 -0
  56. package/packages/crouter-api/dist/core/ledger/payer.js +4 -0
  57. package/packages/crouter-api/dist/core/llm/run.js +2 -1
  58. package/packages/crouter-api/dist/core/permissions/evaluator.js +5 -3
  59. package/packages/crouter-api/dist/core/providers/call.js +2 -2
  60. package/packages/crouter-api/dist/core/runs/node-sub.js +10 -0
  61. package/packages/crouter-api/dist/core/runtime/host.js +2 -2
  62. package/packages/crouter-api/dist/core/runtime/spawn.js +1 -1
  63. package/packages/crouter-api/dist/core/runtime/start-check.js +2 -2
  64. package/packages/crouter-api/dist/core/runtime/warm-pool.js +1 -1
  65. package/packages/crouter-api/dist/core/spaces/process.js +5 -4
  66. package/packages/crouter-api/dist/daemon/api/handlers/bash-jobs.js +1 -1
  67. package/packages/crouter-api/package.json +1 -1
  68. package/packages/crouter-identity/package.json +1 -1
  69. package/packages/crouter-plugin/package.json +3 -3
  70. package/runtime.lock.json +14 -14
@@ -3,7 +3,7 @@ import { parseScope } from '@north-light/identity';
3
3
  import { openDb, withCanvasWrite } from '../canvas/db.js';
4
4
  import { isUnsandboxedMachine } from '../runtime/unsandboxed.js';
5
5
  import { replaceWrittenBy, userSubject } from '../permissions/facts.js';
6
- import { GROUP_TYPE } from '../permissions/builtin.js';
6
+ import { GROUP_TYPE, OBJECT_TYPE } from '../permissions/builtin.js';
7
7
  import { shadowCheck } from './shadow.js';
8
8
  const SETUP_STATES = ['not_started', 'pending', 'ready', 'failed', 'unavailable'];
9
9
  const STRENGTHS = ['ultra', 'strong', 'medium', 'light'];
@@ -461,11 +461,26 @@ export async function replaceGrants(grants, syncedAt, source, teams = []) {
461
461
  changed += Number((await upsert.run(grant.id, grant.runtime, grant.sub, grant.grantee, grant.rev, JSON.stringify(grant.scopes), JSON.stringify(grant.resolved_scopes), grant.spend_cap, grant.expires_at, grant.status, grant.revoked_at, grant.approved_at, grant.payer, JSON.stringify(dependenciesOf(grant.dependencies)), grant.run_notice_url ?? null, grant.inference_endpoint ? JSON.stringify(grant.inference_endpoint) : null, grant.synced_at, grant.rev)).changes);
462
462
  }
463
463
  await replaceWrittenBy(db, 'directory', GROUP_TYPE, 'member', teams.flatMap(({ team, members }) => members.map((member) => ({ resourceId: team, subject: userSubject(member) }))));
464
+ await reconcileAppAdminFacts(db);
464
465
  await db.prepare("INSERT INTO runtime_state (key, value) VALUES ('grants_source', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(source);
465
466
  if (changed > 0)
466
467
  await db.prepare("INSERT INTO runtime_state (key, value) VALUES ('grants_generation', '1') ON CONFLICT(key) DO UPDATE SET value = CAST(CAST(runtime_state.value AS INTEGER) + 1 AS TEXT)").run();
467
468
  });
468
469
  }
470
+ /** The relations an app's admins hold on the app object: they reach its profiles, environments and nodes through `parent->` (app-runtimes D8). */
471
+ const ADMIN_RELATIONS = ['editor', 'messenger', 'user_of'];
472
+ export const APP_ADMIN_WRITER = 'app-admin';
473
+ /** Make `editor`, `messenger` and `user_of` on each app object exactly its app's `admin` tuples (a `user` or a `crtr/group#member` team),
474
+ * so a removed admin loses them. Runs in the caller's transaction; the admin tuples are the directory's, the facts it writes are `written_by = 'app-admin'`. */
475
+ export async function reconcileAppAdminFacts(db) {
476
+ const admins = await db.prepare(`SELECT o.id AS object, r.subject_type, r.subject_id FROM objects o
477
+ JOIN relations r ON r.resource_type = 'app' AND r.resource_id = o.name AND r.relation = 'admin' AND r.subject_type IN ('user', ?)
478
+ WHERE o.type = 'app' AND o.deleted_at IS NULL`).all(GROUP_TYPE);
479
+ const facts = admins.map((a) => ({ resourceId: a.object,
480
+ subject: a.subject_type === GROUP_TYPE ? { type: GROUP_TYPE, id: a.subject_id, relation: 'member' } : { type: 'user', id: a.subject_id, relation: '' } }));
481
+ for (const relation of ADMIN_RELATIONS)
482
+ await replaceWrittenBy(db, APP_ADMIN_WRITER, OBJECT_TYPE, relation, facts);
483
+ }
469
484
  /** Bumped by every `replaceGrants`. A launch compiled against one generation
470
485
  * and started under another may hold mounts the new mirror no longer grants. */
471
486
  export async function grantsGeneration() {
@@ -14,7 +14,7 @@ import { checkCronFire } from '../../daemon/cron/authority.js';
14
14
  import { cronExecutionFor } from '../../daemon/cron/live-runs.js';
15
15
  import { cronExecutionsReady } from '../../daemon/cron/run-socket.js';
16
16
  import { flatMapAsync } from '../async-array.js';
17
- import { personId } from '../canvas/person.js';
17
+ import { launchSub } from '../runs/node-sub.js';
18
18
  async function appUserOwners() {
19
19
  return new Map((await (await openDb()).prepare('SELECT uid, app, status FROM app_users').all())
20
20
  .map((row) => [row.uid, { app: row.app, status: row.status }]));
@@ -51,7 +51,7 @@ export async function exceeds(sandbox, owners) {
51
51
  permissions = await permissionsForRun(cronExecution.grantee, cronExecution.sub, cronExecution.grantId, cronScopes);
52
52
  }
53
53
  else if (node && node.grantee === owner.app) {
54
- permissions = await permissionsForRun(owner.app, node.sub ?? personId(), node.grant_id ?? null, node.scopes ?? null);
54
+ permissions = await permissionsForRun(owner.app, launchSub(node.sub, node.node_id), node.grant_id ?? null, node.scopes ?? null);
55
55
  }
56
56
  else {
57
57
  // A process without a node (an unanchored cron, a delivery) runs on the app's whole grant.
@@ -0,0 +1,15 @@
1
+ // The payer stored on the environment a profile or node runs in (`environments.payer`); null when the profile has no environment
2
+ // or the environment names none, in which case the run's `sub` pays as before.
3
+ import { openDb } from '../canvas/db.js';
4
+ export async function environmentPayerOfProfile(profileId) {
5
+ if (!profileId)
6
+ return null;
7
+ const row = await (await openDb()).prepare('SELECT e.payer AS payer FROM profiles p JOIN environments e ON e.object = p.environment_id WHERE p.id = ?').get(profileId);
8
+ return row?.payer ?? null;
9
+ }
10
+ export async function environmentPayerOfNode(nodeId) {
11
+ if (!nodeId)
12
+ return null;
13
+ const row = await (await openDb()).prepare('SELECT e.payer AS payer FROM nodes n JOIN profiles p ON p.id = n.profile_id JOIN environments e ON e.object = p.environment_id WHERE n.node_id = ?').get(nodeId);
14
+ return row?.payer ?? null;
15
+ }
@@ -1,6 +1,7 @@
1
1
  // The ledger core (design-ledger, cycle 4). Every site calls these.
2
2
  export * from './types.js';
3
3
  export * from './months.js';
4
+ export { environmentPayerOfNode, environmentPayerOfProfile } from './environment-payer.js';
4
5
  export { payerOf } from './payer.js';
5
6
  export { writeCharge, receiptChargeId, chargeOf } from './charges.js';
6
7
  export { check, findRefusal, refusalError, refusedMark, userActionOf } from './check.js';
@@ -2,6 +2,10 @@
2
2
  // never a request header, so a caller cannot name its payer.
3
3
  /** Who pays, and with what funding. A device call is not priced and never asks. */
4
4
  export function payerOf(call) {
5
+ const paid = fundedBy(call);
6
+ return call.environmentPayer ? { payer: call.environmentPayer, funding: paid.funding } : paid;
7
+ }
8
+ function fundedBy(call) {
5
9
  switch (call.call) {
6
10
  case 'model':
7
11
  return call.route === 'endpoint' ? { payer: call.grantee, funding: 'endpoint' } : { payer: call.sub, funding: call.route };
@@ -324,7 +324,8 @@ export async function runLlm(input, signal, onChunk, target, spend, caller, caus
324
324
  const served = `${model.provider}/${model.id}`;
325
325
  const requested = input.model ?? served;
326
326
  // The ledger check, once the account, key or endpoint is chosen and before this candidate's vendor request or token mint.
327
- const paid = hosted ? (sub === null ? null : { payer: sub, funding: 'endpoint' }) : app ? payerOf({ call: 'model', route: 'endpoint', grantee: app.grantee }) : sub === null ? null : payerOf({ call: 'model', route: account ? 'subscription' : 'key', sub });
327
+ const environmentPayer = spend?.environmentPayer;
328
+ const paid = hosted ? (sub === null ? null : { payer: environmentPayer ?? sub, funding: 'endpoint' }) : app ? payerOf({ call: 'model', route: 'endpoint', grantee: app.grantee, environmentPayer }) : sub === null ? null : payerOf({ call: 'model', route: account ? 'subscription' : 'key', sub, environmentPayer });
328
329
  if (spend !== undefined && paid !== null) {
329
330
  const refusal = await findRefusal({ scope: 'call', payer: paid.payer, funding: paid.funding, sub, grantee: spend.grantee, provider });
330
331
  if (refusal !== null) {
@@ -10,6 +10,8 @@ export const PERMISSIONS = ['read', 'edit', 'message', 'use', 'share'];
10
10
  /** The ceiling access class a permission asks: read/use → read, edit/share → write, message → message. */
11
11
  const ACCESS = { read: 'read', use: 'read', edit: 'write', share: 'write', message: 'message' };
12
12
  const bareUser = (principal) => principal.replace(/^user:/, '');
13
+ /** An app acting as its own subject (`app:<id>`) is no person: it never becomes a user, so no `acts_for` or subject set is built from it. */
14
+ const personSub = (sub) => sub.startsWith('app:') ? null : bareUser(sub);
13
15
  /** The user a reader acts for: a person's own identity; an app call's `sub`; a node's `sub`; otherwise the install's person. */
14
16
  export async function userOf(db, reader) {
15
17
  return await namedUserOf(db, reader) ?? bareUser(await personIdAsync());
@@ -21,12 +23,12 @@ async function namedUserOf(db, reader) {
21
23
  return row === undefined ? null : bareUser(row.external_id);
22
24
  }
23
25
  if (reader.class === 'app')
24
- return reader.sub === undefined ? null : bareUser(reader.sub);
26
+ return reader.sub === undefined ? null : personSub(reader.sub);
25
27
  if (reader.class === 'object' && reader.sub !== undefined)
26
- return bareUser(reader.sub);
28
+ return personSub(reader.sub);
27
29
  const nodeId = reader.class === 'node' ? reader.node.id : reader.object.id;
28
30
  const row = await db.prepare('SELECT sub FROM nodes WHERE node_id = ?').get(nodeId);
29
- return row?.sub == null ? null : bareUser(row.sub);
31
+ return row?.sub == null ? null : personSub(row.sub);
30
32
  }
31
33
  /** The user ids a subject stands for (the user and `*`) and every group it reaches, directly or through nested groups. */
32
34
  export async function subjectSet(db, userId) {
@@ -1,7 +1,7 @@
1
1
  import { validateDeclaredResult } from '../../api/command-manifest/result.js';
2
2
  import { callerAllows, requireGroup } from '../../daemon/api/handlers/providers.js';
3
3
  import { callerTerminalGrant } from '../grants/terminal.js';
4
- import { findRefusal, payerOf, refusalError, refusedMark, writeCharge } from '../ledger/index.js';
4
+ import { environmentPayerOfNode, findRefusal, payerOf, refusalError, refusedMark, writeCharge } from '../ledger/index.js';
5
5
  import { listInstalledPlugins } from '../resolver.js';
6
6
  import { emitEvent } from '../events/emit.js';
7
7
  import { ProviderError, scopeMissing } from './errors.js';
@@ -282,7 +282,7 @@ export async function callProvider(caller, rawInput, request) {
282
282
  jti = token.jti;
283
283
  // The payer is the token's claim, so the check runs once the token is in hand and before anything is sent to the provider.
284
284
  const chargeGrantee = caller.class === 'person' ? TERMINAL_GRANTEE : grantee;
285
- const paid = payerOf({ call: 'tool', tokenPayer: token.payer, sub });
285
+ const paid = payerOf({ call: 'tool', tokenPayer: token.payer, sub, environmentPayer: await environmentPayerOfNode(caller.node_id) });
286
286
  const refusal = await findRefusal({ scope: 'call', payer: paid.payer, funding: paid.funding, sub, grantee: chargeGrantee, provider: `app:${bundle.id}` });
287
287
  if (refusal !== null) {
288
288
  await writeCharge({ request: requestId, kind: 'tool', what: `${bundle.id}:${input.tool}`, usd: 0, payer: paid.payer, funding: paid.funding, sub, grantee: chargeGrantee,
@@ -0,0 +1,10 @@
1
+ import { isCloudRole, personId } from '../canvas/person.js';
2
+ import { RunError } from './operations.js';
3
+ /** The subject a node launches as. A node carries its own `sub`; only an unjoined single-person install, whose nodes may predate it, falls back to the install's person. A cloud role never does: it serves many subjects and has no person of its own. */
4
+ export function launchSub(sub, nodeId) {
5
+ if (sub != null)
6
+ return sub;
7
+ if (isCloudRole())
8
+ throw new RunError(500, 'node_without_sub', `node ${nodeId} has no sub`);
9
+ return personId();
10
+ }
@@ -43,7 +43,7 @@ import { bindBrokerEventSource, eventSource } from '../events/source.js';
43
43
  import { envBrokerEngine } from '../../shared/env.js';
44
44
  import { conversationIdFromPath, conversationStore, ConversationNotFoundError } from '../conversation-store/index.js';
45
45
  import { mintNodeToken } from '../canvas/node-tokens.js';
46
- import { personId } from '../canvas/person.js';
46
+ import { launchSub } from '../runs/node-sub.js';
47
47
  // HeadlessBrokerHost (design §3.3): a detached broker PROCESS, no tmux pane. It
48
48
  // boots the dedicated broker-cli entry directly (NEVER src/cli.ts), supervises
49
49
  // via the broker pid recorded as pi_pid, and tears down over the node's unix
@@ -532,7 +532,7 @@ export const headlessBrokerHost = {
532
532
  // The second serves the one relaunch a grant sync during launch can force.
533
533
  const readFds = [openSync(`/proc/self/fd/${tokenFd}`, 'r'), openSync(`/proc/self/fd/${tokenFd}`, 'r')];
534
534
  closeSync(tokenFd);
535
- const launchNode = { nodeId, app, sub: row.sub ?? personId(), grantId: row.grant_id ?? null,
535
+ const launchNode = { nodeId, app, sub: launchSub(row.sub, nodeId), grantId: row.grant_id ?? null,
536
536
  scopes: row.scopes ?? null, isolated: row.isolated === true,
537
537
  ...(row.isolated === true ? { cwd: row.cwd } : {}),
538
538
  command: [process.execPath, resolveBrokerEntry(), '--canvas-home', crtrHome(), '--epoch', fleet.epoch(), nodeId],
@@ -441,7 +441,7 @@ export async function spawnChildPrepared(opts, beforeBrokerLaunch, afterNodeCrea
441
441
  })).launch, launchGrant, opts.model);
442
442
  await assertLaunchModelRegistered(requestFromLaunch(preflightLaunch), { cwd: birthCwd, profileId });
443
443
  // The start check, before any worktree or node row exists: a refusal leaves nothing behind.
444
- await checkStart({ grantee: payerSource?.grantee ?? 'app:terminal', sub: payerSource?.sub, grant_id: payerSource?.grant_id });
444
+ await checkStart({ grantee: payerSource?.grantee ?? 'app:terminal', sub: payerSource?.sub, grant_id: payerSource?.grant_id, profile_id: profileId });
445
445
  const forkSourceNodeId = forkSourceMeta?.node_id ?? null;
446
446
  let managedWorktree;
447
447
  let spawnCwd = birthCwd;
@@ -1,6 +1,6 @@
1
1
  // The start check (design-ledger, "The check → Start check"): run before a node is born, a run starts, a cron fires, a job
2
2
  // starts or a dormant node revives. The candidate's payer is whoever pays the node's model calls.
3
- import { check, findRefusal, payerOf } from '../ledger/index.js';
3
+ import { check, environmentPayerOfProfile, findRefusal, payerOf } from '../ledger/index.js';
4
4
  import { RunError } from '../runs/operations.js';
5
5
  import { grantStanding, payerOfGrant } from '../grants/mirror.js';
6
6
  import { callerTerminalGrant } from '../grants/terminal.js';
@@ -11,7 +11,7 @@ export async function startCandidateOf(who) {
11
11
  if (sub === null)
12
12
  return null;
13
13
  const paid = await payerOfGrant(who.grant_id);
14
- const payer = payerOf({ call: 'start', grantPayer: paid, sub, grantee });
14
+ const payer = payerOf({ call: 'start', grantPayer: paid, sub, grantee, environmentPayer: await environmentPayerOfProfile(who.profile_id) });
15
15
  return { scope: 'start', payer: payer.payer, sub, grantee };
16
16
  }
17
17
  /** Throw `402 cap_exhausted` (limit named) when a limit covering every charge of this identity's payer is reached. */
@@ -123,7 +123,7 @@ async function resolveRecipe(request) {
123
123
  * and the create request uncommitted. A claimed spare is a started node like any birth. */
124
124
  async function checkClaimantStart(request) {
125
125
  const creator = request.creator === null ? null : await getNode(request.creator);
126
- await checkStart({ grantee: creator?.grantee ?? 'app:terminal', sub: creator?.sub, grant_id: creator?.grant_id });
126
+ await checkStart({ grantee: creator?.grantee ?? 'app:terminal', sub: creator?.sub, grant_id: creator?.grant_id, profile_id: creator?.profile_id });
127
127
  }
128
128
  /** Claim a spare for `request`, reshaped onto its persona — or null when the
129
129
  * pool cannot serve it. The caller falls back to a cold spawn; a refused
@@ -13,7 +13,8 @@ import { pinSandboxRuntimeHome } from './runtime-home.js';
13
13
  import { sandboxCacheEnv } from './cache-env.js';
14
14
  import { launcherRequest } from '../../launcher/client.js';
15
15
  import { LAUNCHER_SOCKET } from '../../launcher/spec.js';
16
- import { isCloudRole, personId } from '../canvas/person.js';
16
+ import { isCloudRole } from '../canvas/person.js';
17
+ import { launchSub } from '../runs/node-sub.js';
17
18
  /** The launcher's node id for one cron execution; its run folder is `nodeRunDir(<this>)`. */
18
19
  export function cronLaunchId(executionId) { return `cron-${executionId}`; }
19
20
  /** The same mount compiler and launcher request used by broker launches. A node
@@ -48,7 +49,7 @@ export async function cwdIsMounted(app, cwd, nodeId, isolated = false, folder, p
48
49
  const spec = await compileLaunch({ nodeId: nodeId ?? `proc-cwd-check`, app,
49
50
  ...(principal !== undefined
50
51
  ? { sub: principal.sub, grantId: grant?.id ?? null, scopes: principal.scopes }
51
- : { sub: row ? row.sub ?? personId() : grant.sub, grantId: row ? row.grant_id ?? null : grant.id, scopes: row?.scopes ?? null }),
52
+ : { sub: row ? launchSub(row.sub, row.node_id) : grant.sub, grantId: row ? row.grant_id ?? null : grant.id, scopes: row?.scopes ?? null }),
52
53
  command: ['true'], env: {},
53
54
  ...(nodeId === undefined ? { withoutNode: true } : {}),
54
55
  ...(folder === undefined ? {} : { folder }),
@@ -91,7 +92,7 @@ export async function launchAppProcess(options) {
91
92
  throw new Error(`no active grant for ${app}`);
92
93
  }
93
94
  else if (row) {
94
- if (app !== 'app:terminal' && !(row.grant_id ? await activeGrant(row.grant_id) : await grantFor(app, row.sub ?? personId()))) {
95
+ if (app !== 'app:terminal' && !(row.grant_id ? await activeGrant(row.grant_id) : await grantFor(app, launchSub(row.sub, row.node_id)))) {
95
96
  throw new Error(`no active grant for ${app}`);
96
97
  }
97
98
  }
@@ -117,7 +118,7 @@ export async function launchAppProcess(options) {
117
118
  }).filter((entry) => entry[1] !== undefined)));
118
119
  const launchNode = stored !== undefined
119
120
  ? { nodeId, app, sub: stored.sub, grantId: grant?.id ?? null, scopes: stored.scopes }
120
- : { nodeId, app, sub: row ? row.sub ?? personId() : grant.sub, grantId: row ? row.grant_id ?? null : grant.id, scopes: row?.scopes ?? null };
121
+ : { nodeId, app, sub: row ? launchSub(row.sub, row.node_id) : grant.sub, grantId: row ? row.grant_id ?? null : grant.id, scopes: row?.scopes ?? null };
121
122
  const compile = async () => {
122
123
  const spec = await compileLaunch({ ...launchNode, command: options.command, env,
123
124
  ...(options.nodeId === undefined ? { withoutNode: true } : {}),
@@ -62,7 +62,7 @@ async function handleStart(ctx) {
62
62
  }
63
63
  // The start check with the node's payer, before the job is marked started: a refusal launches nothing.
64
64
  const owner = (await getNode(nodeId));
65
- await checkStart({ grantee: owner.grantee ?? 'app:terminal', sub: owner.sub, grant_id: owner.grant_id });
65
+ await checkStart({ grantee: owner.grantee ?? 'app:terminal', sub: owner.sub, grant_id: owner.grant_id, profile_id: owner.profile_id });
66
66
  if (!appProcessSandboxed())
67
67
  throw new ApiError(400, 'invalid_request', 'job.start is only used with the root launcher');
68
68
  const paths = bashJobPaths(dir, jobId);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.746",
3
+ "version": "0.3.748",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/identity",
3
- "version": "0.3.746",
3
+ "version": "0.3.748",
4
4
  "description": "Northlight access-token verification and scope rules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/plugin",
3
- "version": "0.3.746",
3
+ "version": "0.3.748",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "postpack": "node ../../scripts/pack-minify.mjs postpack packages/crouter-plugin"
28
28
  },
29
29
  "dependencies": {
30
- "@north-light/api": "0.3.746",
31
- "@north-light/identity": "0.3.746"
30
+ "@north-light/api": "0.3.748",
31
+ "@north-light/identity": "0.3.748"
32
32
  },
33
33
  "license": "UNLICENSED",
34
34
  "publishConfig": {
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/cli",
3
- "version": "0.3.746",
3
+ "version": "0.3.748",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/cli",
9
- "version": "0.3.746",
9
+ "version": "0.3.748",
10
10
  "hasInstallScript": true,
11
11
  "license": "UNLICENSED",
12
12
  "workspaces": [
@@ -28,8 +28,8 @@
28
28
  "@milkdown/preset-gfm": "^7.22.3",
29
29
  "@milkdown/prose": "^7.22.3",
30
30
  "@milkdown/utils": "^7.22.3",
31
- "@north-light/identity": "0.3.746",
32
- "@north-light/plugin": "0.3.746",
31
+ "@north-light/identity": "0.3.748",
32
+ "@north-light/plugin": "0.3.748",
33
33
  "cron-parser": "^5.6.0",
34
34
  "esbuild": "0.28.2",
35
35
  "jose": "^6.2.12",
@@ -11902,17 +11902,17 @@
11902
11902
  },
11903
11903
  "packages/crouter-api": {
11904
11904
  "name": "@north-light/api",
11905
- "version": "0.3.746",
11905
+ "version": "0.3.748",
11906
11906
  "license": "UNLICENSED"
11907
11907
  },
11908
11908
  "packages/crouter-env-docker": {
11909
11909
  "name": "@north-light/env-docker",
11910
- "version": "0.3.746",
11910
+ "version": "0.3.748",
11911
11911
  "license": "UNLICENSED"
11912
11912
  },
11913
11913
  "packages/crouter-identity": {
11914
11914
  "name": "@north-light/identity",
11915
- "version": "0.3.746",
11915
+ "version": "0.3.748",
11916
11916
  "license": "UNLICENSED",
11917
11917
  "dependencies": {
11918
11918
  "jose": "^6.2.1"
@@ -11920,21 +11920,21 @@
11920
11920
  },
11921
11921
  "packages/crouter-plugin": {
11922
11922
  "name": "@north-light/plugin",
11923
- "version": "0.3.746",
11923
+ "version": "0.3.748",
11924
11924
  "license": "UNLICENSED",
11925
11925
  "dependencies": {
11926
- "@north-light/api": "0.3.746",
11927
- "@north-light/identity": "0.3.746"
11926
+ "@north-light/api": "0.3.748",
11927
+ "@north-light/identity": "0.3.748"
11928
11928
  }
11929
11929
  },
11930
11930
  "packages/crouter-sdk": {
11931
11931
  "name": "@north-light/sdk",
11932
- "version": "0.3.746",
11932
+ "version": "0.3.748",
11933
11933
  "license": "UNLICENSED",
11934
11934
  "dependencies": {
11935
- "@north-light/api": "0.3.746",
11936
- "@north-light/identity": "0.3.746",
11937
- "@north-light/plugin": "0.3.746",
11935
+ "@north-light/api": "0.3.748",
11936
+ "@north-light/identity": "0.3.748",
11937
+ "@north-light/plugin": "0.3.748",
11938
11938
  "jose": "^6.2.1"
11939
11939
  },
11940
11940
  "bin": {