@skrr-ai/cli 0.1.92 → 0.1.94
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/base-command.d.ts +44 -0
- package/dist/base-command.js +96 -0
- package/dist/commands/agents/badge.d.ts +41 -0
- package/dist/commands/agents/badge.js +158 -0
- package/dist/commands/agents/create.d.ts +24 -0
- package/dist/commands/agents/create.js +212 -0
- package/dist/commands/agents/embed.d.ts +20 -0
- package/dist/commands/agents/embed.js +61 -0
- package/dist/commands/agents/operating-plan.d.ts +11 -0
- package/dist/commands/agents/operating-plan.js +54 -0
- package/dist/commands/agents/roles/example.d.ts +11 -0
- package/dist/commands/agents/roles/example.js +30 -0
- package/dist/commands/{commitments/mode.d.ts → agents/roles/export.d.ts} +5 -5
- package/dist/commands/agents/roles/export.js +81 -0
- package/dist/commands/agents/roles/install.d.ts +12 -0
- package/dist/commands/agents/roles/install.js +48 -0
- package/dist/commands/agents/roles/list.d.ts +11 -0
- package/dist/commands/agents/roles/list.js +36 -0
- package/dist/commands/agents/roles/preview.d.ts +14 -0
- package/dist/commands/agents/roles/preview.js +49 -0
- package/dist/commands/agents/roles/withdraw.d.ts +13 -0
- package/dist/commands/agents/roles/withdraw.js +43 -0
- package/dist/commands/agents/share.d.ts +27 -0
- package/dist/commands/agents/share.js +100 -0
- package/dist/commands/agents/vanity.d.ts +21 -0
- package/dist/commands/agents/vanity.js +77 -0
- package/dist/commands/agents/visibility.d.ts +21 -1
- package/dist/commands/agents/visibility.js +112 -0
- package/dist/commands/commands.d.ts +1 -0
- package/dist/commands/commands.js +22 -9
- package/dist/commands/commitments/{autonomy-requests → cadence-requests}/decide.d.ts +5 -7
- package/dist/commands/commitments/{autonomy-requests → cadence-requests}/decide.js +13 -15
- package/dist/commands/commitments/cost.d.ts +1 -1
- package/dist/commands/commitments/cost.js +1 -1
- package/dist/commands/commitments/create.d.ts +0 -7
- package/dist/commands/commitments/create.js +9 -98
- package/dist/commands/commitments/delivery.js +3 -21
- package/dist/commands/commitments/doctor.js +28 -27
- package/dist/commands/commitments/effective-policy.js +5 -36
- package/dist/commands/commitments/evaluations.d.ts +15 -0
- package/dist/commands/commitments/evaluations.js +54 -0
- package/dist/commands/commitments/pack/activate.d.ts +11 -0
- package/dist/commands/commitments/pack/activate.js +22 -0
- package/dist/commands/commitments/pack/bind.js +1 -1
- package/dist/commands/commitments/remediate.js +2 -5
- package/dist/commands/commitments/show.js +1 -1
- package/dist/commands/commitments/update.js +9 -9
- package/dist/commands/commitments/wake-capabilities.d.ts +1 -3
- package/dist/commands/commitments/wake-capabilities.js +5 -21
- package/dist/commands/earnings/attributions.d.ts +17 -0
- package/dist/commands/earnings/attributions.js +82 -0
- package/dist/commands/earnings/index.js +2 -1
- package/dist/commands/generate-recovery-code.js +4 -3
- package/dist/commands/github/allow-tools.d.ts +1 -0
- package/dist/commands/github/app/install.d.ts +1 -0
- package/dist/commands/github/app/status.d.ts +1 -0
- package/dist/commands/github/connect.d.ts +1 -0
- package/dist/commands/github/connections.d.ts +1 -0
- package/dist/commands/github/disconnect.d.ts +1 -0
- package/dist/commands/github/finalize.d.ts +1 -0
- package/dist/commands/github/reconnect.d.ts +1 -0
- package/dist/commands/github/run.d.ts +1 -0
- package/dist/commands/github/tools.d.ts +1 -0
- package/dist/commands/integrations/connections/connect.d.ts +1 -0
- package/dist/commands/integrations/connections/disconnect.d.ts +1 -0
- package/dist/commands/integrations/connections/finalize.d.ts +1 -0
- package/dist/commands/integrations/connections/list.d.ts +1 -0
- package/dist/commands/integrations/connections/reconnect.d.ts +1 -0
- package/dist/commands/integrations/execute.d.ts +1 -0
- package/dist/commands/integrations/search.d.ts +1 -0
- package/dist/commands/integrations/toolkits.d.ts +1 -0
- package/dist/commands/integrations/tools/allow.d.ts +1 -0
- package/dist/commands/integrations/tools/list.d.ts +1 -0
- package/dist/commands/login.js +12 -0
- package/dist/commands/machines/dedicated/logs.d.ts +19 -0
- package/dist/commands/machines/dedicated/logs.js +103 -0
- package/dist/commands/machines/dedicated/power/set.js +1 -1
- package/dist/commands/open.d.ts +24 -0
- package/dist/commands/open.js +74 -0
- package/dist/commands/projects/archive.d.ts +1 -0
- package/dist/commands/projects/archive.js +23 -0
- package/dist/commands/projects/delete.d.ts +1 -0
- package/dist/commands/projects/delete.js +23 -0
- package/dist/commands/projects/list.d.ts +3 -0
- package/dist/commands/projects/list.js +12 -2
- package/dist/commands/spaces/actions/add.js +4 -3
- package/dist/commands/spaces/actions/available.js +3 -2
- package/dist/commands/spaces/actions/list.js +5 -4
- package/dist/commands/spaces/actions/replace.js +6 -5
- package/dist/commands/spaces/archive.js +3 -2
- package/dist/commands/spaces/auto-executor/preview.js +4 -3
- package/dist/commands/spaces/auto-executor/run.js +4 -3
- package/dist/commands/spaces/auto-executor/runs.js +3 -2
- package/dist/commands/spaces/auto-executor/update.js +4 -3
- package/dist/commands/spaces/bootstrap.js +3 -2
- package/dist/commands/spaces/briefs/delete.js +3 -2
- package/dist/commands/spaces/briefs/get.js +3 -2
- package/dist/commands/spaces/briefs/list.js +3 -2
- package/dist/commands/spaces/briefs/set.js +5 -4
- package/dist/commands/spaces/capacity.js +5 -4
- package/dist/commands/spaces/conversations.js +3 -2
- package/dist/commands/spaces/cycles/create.js +3 -2
- package/dist/commands/spaces/cycles/graph.js +2 -1
- package/dist/commands/spaces/cycles/list.js +3 -2
- package/dist/commands/spaces/cycles/settings.js +4 -3
- package/dist/commands/spaces/cycles/show.js +3 -2
- package/dist/commands/spaces/cycles/update.js +3 -2
- package/dist/commands/spaces/delete.js +4 -3
- package/dist/commands/spaces/expertise-suggestions.js +4 -3
- package/dist/commands/spaces/files/delete.js +3 -2
- package/dist/commands/spaces/files/folders/create.js +3 -2
- package/dist/commands/spaces/files/folders/delete.js +3 -2
- package/dist/commands/spaces/files/folders/list.js +3 -2
- package/dist/commands/spaces/files/folders/update.js +3 -2
- package/dist/commands/spaces/files/list.js +3 -2
- package/dist/commands/spaces/files/move.js +3 -2
- package/dist/commands/spaces/files/rename.js +3 -2
- package/dist/commands/spaces/files/upload.js +6 -5
- package/dist/commands/spaces/github-automations/set.js +3 -2
- package/dist/commands/spaces/github-automations/show.js +3 -2
- package/dist/commands/spaces/goals.js +2 -1
- package/dist/commands/spaces/heartbeats/create.js +4 -3
- package/dist/commands/spaces/heartbeats/delete.js +4 -3
- package/dist/commands/spaces/heartbeats/list.js +4 -3
- package/dist/commands/spaces/heartbeats/status.js +3 -2
- package/dist/commands/spaces/heartbeats/update.js +4 -3
- package/dist/commands/spaces/insights.js +5 -4
- package/dist/commands/spaces/labels/add.js +4 -3
- package/dist/commands/spaces/labels/list.js +2 -1
- package/dist/commands/spaces/labels/remove.js +4 -3
- package/dist/commands/spaces/list.d.ts +3 -0
- package/dist/commands/spaces/list.js +11 -2
- package/dist/commands/spaces/live/cards/create.js +3 -2
- package/dist/commands/spaces/live/cards/list.js +3 -2
- package/dist/commands/spaces/live/cards/reorder.js +7 -2
- package/dist/commands/spaces/live/scene.js +4 -3
- package/dist/commands/spaces/members/add.js +7 -6
- package/dist/commands/spaces/members/list.js +4 -3
- package/dist/commands/spaces/members/remove.js +7 -6
- package/dist/commands/spaces/move.js +3 -2
- package/dist/commands/spaces/pin.js +5 -4
- package/dist/commands/spaces/preferences/show.js +4 -3
- package/dist/commands/spaces/preferences/tabs.js +4 -3
- package/dist/commands/spaces/revisions.js +3 -2
- package/dist/commands/spaces/room/ensure.js +5 -4
- package/dist/commands/spaces/room/messages.js +3 -2
- package/dist/commands/spaces/room/show.js +5 -4
- package/dist/commands/spaces/skills/add.js +4 -3
- package/dist/commands/spaces/skills/list.js +3 -2
- package/dist/commands/spaces/skills/pin.js +4 -3
- package/dist/commands/spaces/skills/remove.js +4 -3
- package/dist/commands/spaces/snapshot.js +3 -2
- package/dist/commands/spaces/states/archive.js +3 -2
- package/dist/commands/spaces/states/create.js +3 -2
- package/dist/commands/spaces/states/list.js +3 -2
- package/dist/commands/spaces/states/reorder.js +2 -1
- package/dist/commands/spaces/states/update.js +3 -2
- package/dist/commands/spaces/summary.js +4 -3
- package/dist/commands/spaces/tasks.d.ts +3 -0
- package/dist/commands/spaces/tasks.js +14 -3
- package/dist/commands/spaces/triggers/delete.js +5 -4
- package/dist/commands/spaces/triggers/set.js +4 -3
- package/dist/commands/spaces/triggers/show.js +4 -3
- package/dist/commands/spaces/unarchive.js +3 -2
- package/dist/commands/spaces/update.js +5 -4
- package/dist/commands/spaces/views/create.js +3 -2
- package/dist/commands/spaces/views/list.js +3 -2
- package/dist/commands/spaces/views/reorder.js +6 -3
- package/dist/commands/spaces/views/subscribe.js +2 -1
- package/dist/commands/spaces/views/subscriptions.js +1 -0
- package/dist/commands/spaces/views/unsubscribe.js +2 -1
- package/dist/commands/spaces/widgets/add.js +4 -3
- package/dist/commands/spaces/widgets/list.js +3 -2
- package/dist/commands/spaces/widgets/remove.js +5 -4
- package/dist/commands/spaces/work-graph.js +2 -1
- package/dist/commands/store/install.d.ts +1 -1
- package/dist/commands/store/install.js +24 -8
- package/dist/commands/store/show.d.ts +25 -0
- package/dist/commands/store/show.js +203 -0
- package/dist/commands/store/stats.d.ts +33 -0
- package/dist/commands/store/stats.js +258 -0
- package/dist/commands/tasks/actions/attach.js +1 -1
- package/dist/commands/tasks/actions/detach.js +4 -3
- package/dist/commands/tasks/activity.js +3 -2
- package/dist/commands/tasks/ancestors.js +2 -1
- package/dist/commands/tasks/approvals/create.js +2 -1
- package/dist/commands/tasks/approvals/delete.js +3 -2
- package/dist/commands/tasks/approvals/list.js +5 -4
- package/dist/commands/tasks/approvals/resolve.js +2 -1
- package/dist/commands/tasks/archive.js +3 -2
- package/dist/commands/tasks/assign.js +4 -3
- package/dist/commands/tasks/attachments/delete.js +3 -2
- package/dist/commands/tasks/attachments/download.d.ts +1 -0
- package/dist/commands/tasks/attachments/download.js +20 -1
- package/dist/commands/tasks/attachments/list.js +2 -1
- package/dist/commands/tasks/attachments/set-role.js +2 -1
- package/dist/commands/tasks/attachments/upload.js +2 -1
- package/dist/commands/tasks/bulk-update.d.ts +1 -0
- package/dist/commands/tasks/bulk-update.js +106 -15
- package/dist/commands/tasks/cancel-cascade.d.ts +1 -0
- package/dist/commands/tasks/cancel-cascade.js +13 -3
- package/dist/commands/tasks/cascade-status.js +2 -1
- package/dist/commands/tasks/checkout.js +3 -2
- package/dist/commands/tasks/children.js +2 -1
- package/dist/commands/tasks/comments/add.js +7 -6
- package/dist/commands/tasks/comments/anchor.js +8 -7
- package/dist/commands/tasks/comments/delete.js +3 -2
- package/dist/commands/tasks/comments/list.js +2 -1
- package/dist/commands/tasks/comments/reopen.js +3 -2
- package/dist/commands/tasks/comments/resolve.js +3 -2
- package/dist/commands/tasks/create-tree.d.ts +63 -0
- package/dist/commands/tasks/create-tree.js +197 -4
- package/dist/commands/tasks/delete.js +5 -4
- package/dist/commands/tasks/descendants.js +2 -1
- package/dist/commands/tasks/dri-plan.js +3 -2
- package/dist/commands/tasks/dri-run.js +3 -2
- package/dist/commands/tasks/dri-status.js +2 -1
- package/dist/commands/tasks/duplicate-pipeline.js +2 -1
- package/dist/commands/tasks/execution-summary.js +2 -1
- package/dist/commands/tasks/execution-timeline.js +2 -1
- package/dist/commands/tasks/fork.js +1 -0
- package/dist/commands/tasks/forward.js +4 -3
- package/dist/commands/tasks/handover.js +1 -0
- package/dist/commands/tasks/interrupt.js +3 -2
- package/dist/commands/tasks/labels/attach.js +4 -3
- package/dist/commands/tasks/labels/detach.js +4 -3
- package/dist/commands/tasks/labels/suggest.js +5 -4
- package/dist/commands/tasks/list.d.ts +27 -1
- package/dist/commands/tasks/list.js +101 -3
- package/dist/commands/tasks/move.js +4 -3
- package/dist/commands/tasks/output.js +6 -5
- package/dist/commands/tasks/pause-schedule.js +3 -2
- package/dist/commands/tasks/promote.js +1 -0
- package/dist/commands/tasks/prompt-log.js +2 -1
- package/dist/commands/tasks/release.js +5 -4
- package/dist/commands/tasks/remind.js +2 -1
- package/dist/commands/tasks/replay.js +3 -2
- package/dist/commands/tasks/report.js +1 -0
- package/dist/commands/tasks/resume-schedule.js +3 -2
- package/dist/commands/tasks/retry-schedule.js +3 -2
- package/dist/commands/tasks/retry.js +10 -9
- package/dist/commands/tasks/revisions.js +2 -1
- package/dist/commands/tasks/runs.js +6 -5
- package/dist/commands/tasks/schedule.js +3 -2
- package/dist/commands/tasks/self-schedule.js +6 -5
- package/dist/commands/tasks/skills/pin.js +3 -2
- package/dist/commands/tasks/skills/unpin.js +3 -2
- package/dist/commands/tasks/snooze.js +6 -5
- package/dist/commands/tasks/start-all.js +5 -4
- package/dist/commands/tasks/subscribe.js +1 -0
- package/dist/commands/tasks/tags/add.js +4 -3
- package/dist/commands/tasks/tags/remove.js +4 -3
- package/dist/commands/tasks/timeline.js +3 -2
- package/dist/commands/tasks/today.d.ts +4 -1
- package/dist/commands/tasks/today.js +12 -2
- package/dist/commands/tasks/transcript.js +6 -5
- package/dist/commands/tasks/unschedule.js +3 -2
- package/dist/commands/tasks/unsnooze.js +3 -2
- package/dist/commands/tasks/unsubscribe.js +2 -1
- package/dist/commands/tasks/update.js +5 -4
- package/dist/commands/tasks/wait.js +5 -4
- package/dist/lib/agent-distribution.d.ts +37 -0
- package/dist/lib/agent-distribution.js +63 -0
- package/dist/lib/agent-ref.d.ts +69 -0
- package/dist/lib/agent-ref.js +168 -0
- package/dist/lib/api-fetch.d.ts +2 -0
- package/dist/lib/api-fetch.js +14 -3
- package/dist/lib/command-hygiene.d.ts +13 -0
- package/dist/lib/command-hygiene.js +62 -2
- package/dist/lib/commitment-product.d.ts +0 -6
- package/dist/lib/commitment-product.js +1 -30
- package/dist/lib/commitments.d.ts +9 -45
- package/dist/lib/commitments.js +24 -95
- package/dist/lib/dedicated-power.d.ts +5 -0
- package/dist/lib/dedicated-power.js +30 -2
- package/dist/lib/dry-run-plans.d.ts +50 -0
- package/dist/lib/dry-run-plans.js +85 -0
- package/dist/lib/json-output.d.ts +31 -0
- package/dist/lib/json-output.js +78 -0
- package/dist/lib/list-output.d.ts +75 -0
- package/dist/lib/list-output.js +266 -0
- package/dist/lib/machine-daemon-log.d.ts +36 -0
- package/dist/lib/machine-daemon-log.js +78 -0
- package/dist/lib/node-adapter.js +10 -1
- package/dist/lib/northstars.js +1 -1
- package/dist/lib/open-target.d.ts +12 -0
- package/dist/lib/open-target.js +108 -0
- package/dist/lib/rate-limit-retry.d.ts +45 -0
- package/dist/lib/rate-limit-retry.js +88 -0
- package/dist/lib/roles.d.ts +98 -0
- package/dist/lib/roles.js +45 -0
- package/dist/lib/store-listing.d.ts +45 -0
- package/dist/lib/store-listing.js +186 -0
- package/dist/lib/task-batch.d.ts +67 -0
- package/dist/lib/task-batch.js +227 -0
- package/dist/lib/terminal-qr.d.ts +55 -0
- package/dist/lib/terminal-qr.js +119 -0
- package/dist/lib/web-url.d.ts +11 -0
- package/dist/lib/web-url.js +24 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.d.ts +45 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/commitmentExecutionContract.js +550 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerWire.d.ts +68 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerWire.js +47 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/sessionPermissionAuthority.d.ts +7 -44
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/sessionPermissionAuthority.js +8 -47
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.d.ts +45 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/commitmentExecutionContract.js +545 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerWire.d.ts +68 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerWire.js +46 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/sessionPermissionAuthority.d.ts +7 -44
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/sessionPermissionAuthority.js +8 -47
- package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +7285 -6673
- package/dist/node_modules/@skrr-ai/data-provider/package.json +2 -2
- package/oclif.manifest.json +35937 -26820
- package/package.json +6 -2
- package/dist/commands/commitments/autonomy.d.ts +0 -30
- package/dist/commands/commitments/autonomy.js +0 -67
- package/dist/commands/commitments/mode.js +0 -58
- package/dist/commands/commitments/pack/promote.d.ts +0 -19
- package/dist/commands/commitments/pack/promote.js +0 -46
- package/dist/commands/commitments/pack/shadow.d.ts +0 -20
- package/dist/commands/commitments/pack/shadow.js +0 -42
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COMMITMENT_EXECUTION_CONTRACT_CAPABILITY = exports.COMMITMENT_EXECUTION_CONTRACT_VERSION = void 0;
|
|
4
|
+
exports.eventRepository = eventRepository;
|
|
5
|
+
exports.normalizeCommitmentExecutionContract = normalizeCommitmentExecutionContract;
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
7
|
+
/** Mode-free responsibility context. Tool permissions belong to the Agent runtime. */
|
|
8
|
+
exports.COMMITMENT_EXECUTION_CONTRACT_VERSION = 3;
|
|
9
|
+
exports.COMMITMENT_EXECUTION_CONTRACT_CAPABILITY = 'commitment_execution_contract_v3';
|
|
10
|
+
const DELIVERY_MODES = new Set([
|
|
11
|
+
'report_only',
|
|
12
|
+
'local_patch',
|
|
13
|
+
'draft_pr',
|
|
14
|
+
'push_branch',
|
|
15
|
+
'direct_branch',
|
|
16
|
+
]);
|
|
17
|
+
const FACT_KEYS = new Set([
|
|
18
|
+
'id',
|
|
19
|
+
'source',
|
|
20
|
+
'type',
|
|
21
|
+
'eventType',
|
|
22
|
+
'checkName',
|
|
23
|
+
'workflowName',
|
|
24
|
+
'workflowRunId',
|
|
25
|
+
'revision',
|
|
26
|
+
'appId',
|
|
27
|
+
'appSlug',
|
|
28
|
+
'slug',
|
|
29
|
+
'app',
|
|
30
|
+
'action',
|
|
31
|
+
'status',
|
|
32
|
+
'conclusion',
|
|
33
|
+
'sha',
|
|
34
|
+
'headSha',
|
|
35
|
+
'head_sha',
|
|
36
|
+
'branch',
|
|
37
|
+
'headBranch',
|
|
38
|
+
'head_branch',
|
|
39
|
+
'repo',
|
|
40
|
+
'repository',
|
|
41
|
+
'fullName',
|
|
42
|
+
'full_name',
|
|
43
|
+
'repoFullName',
|
|
44
|
+
'prNumber',
|
|
45
|
+
'owner',
|
|
46
|
+
'name',
|
|
47
|
+
'number',
|
|
48
|
+
'checkRunId',
|
|
49
|
+
'check_run_id',
|
|
50
|
+
'runId',
|
|
51
|
+
'run_id',
|
|
52
|
+
'url',
|
|
53
|
+
'runUrl',
|
|
54
|
+
'htmlUrl',
|
|
55
|
+
'html_url',
|
|
56
|
+
'createdAt',
|
|
57
|
+
'updatedAt',
|
|
58
|
+
'occurredAt',
|
|
59
|
+
'completed_at',
|
|
60
|
+
'started_at',
|
|
61
|
+
'check_run',
|
|
62
|
+
'check_suite',
|
|
63
|
+
'workflow_run',
|
|
64
|
+
'pull_request',
|
|
65
|
+
'base',
|
|
66
|
+
'head',
|
|
67
|
+
'ref',
|
|
68
|
+
'eventId',
|
|
69
|
+
'rerun',
|
|
70
|
+
'checkAnnotations',
|
|
71
|
+
'path',
|
|
72
|
+
'startLine',
|
|
73
|
+
'endLine',
|
|
74
|
+
'level',
|
|
75
|
+
'message',
|
|
76
|
+
'title',
|
|
77
|
+
]);
|
|
78
|
+
const CAPABILITY_SOURCE_KEYS = new Set([
|
|
79
|
+
'source',
|
|
80
|
+
'provider',
|
|
81
|
+
'capability',
|
|
82
|
+
'scope',
|
|
83
|
+
'status',
|
|
84
|
+
'attestation',
|
|
85
|
+
'accountFingerprint',
|
|
86
|
+
'testedAt',
|
|
87
|
+
'expiresAt',
|
|
88
|
+
'runtimeId',
|
|
89
|
+
'reason',
|
|
90
|
+
]);
|
|
91
|
+
const WORKSPACE_CONSTRAINT_KEYS = new Set([
|
|
92
|
+
'allowedCommitmentDeliveryModes',
|
|
93
|
+
'requireAttestedAccessForDeliveryModes',
|
|
94
|
+
'maxInitiativesPerDay',
|
|
95
|
+
'maxAutoRunsPerDay',
|
|
96
|
+
'maxCommitmentActionRunsPerDay',
|
|
97
|
+
'maxCommitmentObservationRunsPerDay',
|
|
98
|
+
'maxCommitmentConcurrentRuns',
|
|
99
|
+
'maxCommitmentCostUsdPerDay',
|
|
100
|
+
'requireApprovalRiskLevels',
|
|
101
|
+
'requireApprovalActionClasses',
|
|
102
|
+
'blockedSourceKinds',
|
|
103
|
+
]);
|
|
104
|
+
const CAPABILITY_SOURCES = new Set([
|
|
105
|
+
'event_payload',
|
|
106
|
+
'cloud_runtime',
|
|
107
|
+
'local_harness',
|
|
108
|
+
'platform_grant',
|
|
109
|
+
]);
|
|
110
|
+
const CAPABILITY_STATUSES = new Set(['available', 'unavailable', 'unknown', 'stale']);
|
|
111
|
+
const CAPABILITY_ATTESTATIONS = new Set(['platform', 'runtime', 'machine', 'none']);
|
|
112
|
+
function plainObject(value) {
|
|
113
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
114
|
+
return false;
|
|
115
|
+
const prototype = Object.getPrototypeOf(value);
|
|
116
|
+
return prototype === Object.prototype || prototype === null;
|
|
117
|
+
}
|
|
118
|
+
function hasOnlyKeys(value, allowed) {
|
|
119
|
+
return plainObject(value) && Object.keys(value).every((key) => allowed.has(key));
|
|
120
|
+
}
|
|
121
|
+
function boundedString(value, max = 1000) {
|
|
122
|
+
return typeof value === 'string' && value.length > 0 && value.length <= max;
|
|
123
|
+
}
|
|
124
|
+
function optionalString(value, max = 1000) {
|
|
125
|
+
return typeof value === 'string' && value.length <= max;
|
|
126
|
+
}
|
|
127
|
+
function isoTimestamp(value) {
|
|
128
|
+
return (typeof value === 'string' &&
|
|
129
|
+
value.length <= 40 &&
|
|
130
|
+
Number.isFinite(Date.parse(value)) &&
|
|
131
|
+
new Date(value).toISOString() === value);
|
|
132
|
+
}
|
|
133
|
+
function normalizedEventFactValue(item, depth) {
|
|
134
|
+
if (typeof item === 'string') {
|
|
135
|
+
if (containsCredentialSignature(item))
|
|
136
|
+
return undefined;
|
|
137
|
+
return item.slice(0, 1000);
|
|
138
|
+
}
|
|
139
|
+
if (typeof item === 'number' || typeof item === 'boolean')
|
|
140
|
+
return item;
|
|
141
|
+
if (Array.isArray(item)) {
|
|
142
|
+
return item
|
|
143
|
+
.slice(0, 20)
|
|
144
|
+
.map((entry) => normalizedEventFacts(entry, depth + 1))
|
|
145
|
+
.filter((entry) => entry !== undefined);
|
|
146
|
+
}
|
|
147
|
+
return normalizedEventFacts(item, depth + 1);
|
|
148
|
+
}
|
|
149
|
+
const CREDENTIAL_SIGNATURE_RE = /(?:bearer\s+(?!\[REDACTED\](?:\s|$))\S{8,}|github_pat_[A-Za-z0-9_]{8,}|gh[pousr]_[A-Za-z0-9_]{8,}|xox[baprs]-[A-Za-z0-9-]{8,}|sk_(?:live|test)_[A-Za-z0-9]{8,}|(?:AKIA|ASIA)[A-Z0-9]{16}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:(?!\[REDACTED\]@)[^\s/@]+@|-----BEGIN [A-Z ]*PRIVATE KEY-----)/i;
|
|
150
|
+
function containsCredentialSignature(value) {
|
|
151
|
+
return typeof value === 'string' && CREDENTIAL_SIGNATURE_RE.test(value);
|
|
152
|
+
}
|
|
153
|
+
function normalizedEventFacts(value, depth = 0) {
|
|
154
|
+
if (!plainObject(value) || depth > 3)
|
|
155
|
+
return undefined;
|
|
156
|
+
return Object.fromEntries(Object.entries(value)
|
|
157
|
+
.filter(([key]) => FACT_KEYS.has(key))
|
|
158
|
+
.slice(0, 30)
|
|
159
|
+
.map(([key, item]) => [key, normalizedEventFactValue(item, depth)])
|
|
160
|
+
.filter(([, item]) => item !== undefined));
|
|
161
|
+
}
|
|
162
|
+
const CI_LOG_EVIDENCE_KEYS = new Set([
|
|
163
|
+
'version',
|
|
164
|
+
'provider',
|
|
165
|
+
'kind',
|
|
166
|
+
'repoFullName',
|
|
167
|
+
'checkRunId',
|
|
168
|
+
'workflowRunId',
|
|
169
|
+
'jobId',
|
|
170
|
+
'capability',
|
|
171
|
+
'attestation',
|
|
172
|
+
'fetchedAt',
|
|
173
|
+
'status',
|
|
174
|
+
'reason',
|
|
175
|
+
'byteLength',
|
|
176
|
+
'lineCount',
|
|
177
|
+
'excerptLines',
|
|
178
|
+
'excerpt',
|
|
179
|
+
'digest',
|
|
180
|
+
// Attribution facts, taken off the job row the server had to fetch to prove
|
|
181
|
+
// identity. Allowed on an UNREADABLE row: attribution happens before the
|
|
182
|
+
// download, so the failing step name survives a log the server could not
|
|
183
|
+
// read. Only text FROM the log is withheld when the read failed.
|
|
184
|
+
'jobName',
|
|
185
|
+
'failedStepName',
|
|
186
|
+
'failedStepNumber',
|
|
187
|
+
]);
|
|
188
|
+
const CI_LOG_EVIDENCE_STATUSES = new Set(['available', 'truncated', 'unavailable', 'unauthorized']);
|
|
189
|
+
const CI_LOG_EVIDENCE_READABLE = new Set(['available', 'truncated']);
|
|
190
|
+
const CI_LOG_EXCERPT_MAX_CHARS = 12_000;
|
|
191
|
+
function validCiLogEvidence(value) {
|
|
192
|
+
if (!hasOnlyKeys(value, CI_LOG_EVIDENCE_KEYS))
|
|
193
|
+
return false;
|
|
194
|
+
if (value.version !== 1 ||
|
|
195
|
+
value.provider !== 'github' ||
|
|
196
|
+
value.kind !== 'actions_job_log' ||
|
|
197
|
+
value.capability !== 'github:actions:read' ||
|
|
198
|
+
value.attestation !== 'platform' ||
|
|
199
|
+
!CI_LOG_EVIDENCE_STATUSES.has(String(value.status)) ||
|
|
200
|
+
!isoTimestamp(value.fetchedAt) ||
|
|
201
|
+
!/^[\w.-]+\/[\w.-]+$/.test(String(value.repoFullName || '')) ||
|
|
202
|
+
!/^\d{1,20}$/.test(String(value.checkRunId || '')))
|
|
203
|
+
return false;
|
|
204
|
+
for (const key of ['workflowRunId', 'jobId']) {
|
|
205
|
+
if (value[key] !== undefined && !/^\d{1,20}$/.test(String(value[key])))
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
for (const key of ['byteLength', 'lineCount', 'excerptLines', 'failedStepNumber']) {
|
|
209
|
+
const item = value[key];
|
|
210
|
+
if (item !== undefined && (!Number.isSafeInteger(item) || item < 0))
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
for (const key of ['jobName', 'failedStepName']) {
|
|
214
|
+
if (value[key] !== undefined && !boundedString(value[key], 200))
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
if (value.reason !== undefined && !/^[a-z0-9_]{1,80}$/.test(String(value.reason)))
|
|
218
|
+
return false;
|
|
219
|
+
if (value.digest !== undefined && !/^[a-f0-9]{16}$/.test(String(value.digest)))
|
|
220
|
+
return false;
|
|
221
|
+
// A read that failed carries no text: an unreadable log must not be able to
|
|
222
|
+
// arrive looking like a readable one.
|
|
223
|
+
if (!CI_LOG_EVIDENCE_READABLE.has(String(value.status))) {
|
|
224
|
+
return value.excerpt === undefined && value.digest === undefined && Boolean(value.reason);
|
|
225
|
+
}
|
|
226
|
+
return boundedString(value.excerpt, CI_LOG_EXCERPT_MAX_CHARS) && value.jobId !== undefined;
|
|
227
|
+
}
|
|
228
|
+
function validEvidence(value) {
|
|
229
|
+
if (!hasOnlyKeys(value, new Set(['version', 'ci'])))
|
|
230
|
+
return false;
|
|
231
|
+
return (value.version === 1 &&
|
|
232
|
+
Array.isArray(value.ci) &&
|
|
233
|
+
value.ci.length >= 1 &&
|
|
234
|
+
value.ci.length <= 4 &&
|
|
235
|
+
value.ci.every(validCiLogEvidence));
|
|
236
|
+
}
|
|
237
|
+
// Mirror of `validObserve` in
|
|
238
|
+
// api/server/services/Commitments/CommitmentExecutionContract.js. The daemon
|
|
239
|
+
// has no projector, so canonical form is part of validity on both sides:
|
|
240
|
+
// `egress` must be strictly ascending (sorted AND unique). The shared parity
|
|
241
|
+
// fixture holds the two to one verdict.
|
|
242
|
+
const OBSERVE_KEYS = new Set(['egress', 'web', 'shell', 'browser']);
|
|
243
|
+
const OBSERVE_EGRESS_MAX = 32;
|
|
244
|
+
const OBSERVE_HOST_PATTERN = /^(\*\.)?[a-z0-9.-]+$/;
|
|
245
|
+
const OBSERVE_HOST_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
246
|
+
function evidenceMatchesEvent(row, event) {
|
|
247
|
+
if (!plainObject(row) || !plainObject(event))
|
|
248
|
+
return true;
|
|
249
|
+
const same = (a, b) => String(a).toLowerCase() === String(b).toLowerCase();
|
|
250
|
+
if (event.repoFullName !== undefined && !same(row.repoFullName, event.repoFullName))
|
|
251
|
+
return false;
|
|
252
|
+
if (event.checkRunId !== undefined && !same(row.checkRunId, event.checkRunId))
|
|
253
|
+
return false;
|
|
254
|
+
if (row.workflowRunId !== undefined &&
|
|
255
|
+
event.workflowRunId !== undefined &&
|
|
256
|
+
!same(row.workflowRunId, event.workflowRunId))
|
|
257
|
+
return false;
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
function validCapabilitySource(value) {
|
|
261
|
+
if (!hasOnlyKeys(value, CAPABILITY_SOURCE_KEYS))
|
|
262
|
+
return false;
|
|
263
|
+
if (!CAPABILITY_SOURCES.has(String(value.source)) ||
|
|
264
|
+
!boundedString(value.provider, 80) ||
|
|
265
|
+
!/^[a-z0-9_.-]{1,80}$/i.test(value.provider) ||
|
|
266
|
+
!boundedString(value.capability, 120) ||
|
|
267
|
+
!/^[a-z0-9_:.-]{1,120}$/i.test(value.capability) ||
|
|
268
|
+
!CAPABILITY_STATUSES.has(String(value.status)) ||
|
|
269
|
+
!CAPABILITY_ATTESTATIONS.has(String(value.attestation)))
|
|
270
|
+
return false;
|
|
271
|
+
if (value.scope !== undefined && !optionalString(value.scope, 500))
|
|
272
|
+
return false;
|
|
273
|
+
if (value.accountFingerprint !== undefined &&
|
|
274
|
+
!/^[a-f0-9]{64}$/i.test(String(value.accountFingerprint)))
|
|
275
|
+
return false;
|
|
276
|
+
if (value.testedAt !== undefined && !isoTimestamp(value.testedAt))
|
|
277
|
+
return false;
|
|
278
|
+
if (value.expiresAt !== undefined && !isoTimestamp(value.expiresAt))
|
|
279
|
+
return false;
|
|
280
|
+
if (value.testedAt &&
|
|
281
|
+
value.expiresAt &&
|
|
282
|
+
Date.parse(String(value.expiresAt)) <= Date.parse(String(value.testedAt)))
|
|
283
|
+
return false;
|
|
284
|
+
if (value.runtimeId !== undefined && !boundedString(value.runtimeId, 200))
|
|
285
|
+
return false;
|
|
286
|
+
if (value.reason !== undefined && !optionalString(value.reason, 1000))
|
|
287
|
+
return false;
|
|
288
|
+
if (value.source === 'event_payload' && value.attestation !== 'platform')
|
|
289
|
+
return false;
|
|
290
|
+
if (value.source === 'platform_grant' && value.attestation !== 'platform')
|
|
291
|
+
return false;
|
|
292
|
+
if (value.source === 'local_harness' &&
|
|
293
|
+
(!['machine', 'none'].includes(String(value.attestation)) ||
|
|
294
|
+
(value.status === 'available' &&
|
|
295
|
+
(value.attestation !== 'machine' ||
|
|
296
|
+
!value.accountFingerprint ||
|
|
297
|
+
!value.testedAt ||
|
|
298
|
+
!value.expiresAt ||
|
|
299
|
+
!value.runtimeId))))
|
|
300
|
+
return false;
|
|
301
|
+
if (value.source === 'cloud_runtime' &&
|
|
302
|
+
(!['runtime', 'none'].includes(String(value.attestation)) ||
|
|
303
|
+
(value.status === 'available' &&
|
|
304
|
+
(value.attestation !== 'runtime' ||
|
|
305
|
+
!value.accountFingerprint ||
|
|
306
|
+
!value.testedAt ||
|
|
307
|
+
!value.expiresAt ||
|
|
308
|
+
!value.runtimeId))))
|
|
309
|
+
return false;
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
function validStringArray(value, max, values) {
|
|
313
|
+
return (Array.isArray(value) &&
|
|
314
|
+
value.length <= max &&
|
|
315
|
+
value.every((item) => boundedString(item, 120) && (!values || values.has(item))));
|
|
316
|
+
}
|
|
317
|
+
function validWorkspacePolicy(value) {
|
|
318
|
+
if (!hasOnlyKeys(value, new Set(['hardStop', 'hardConstraints'])))
|
|
319
|
+
return false;
|
|
320
|
+
if (value.hardStop !== undefined && value.hardStop !== null) {
|
|
321
|
+
if (!hasOnlyKeys(value.hardStop, new Set(['enabled', 'reason', 'scope'])))
|
|
322
|
+
return false;
|
|
323
|
+
if (typeof value.hardStop.enabled !== 'boolean')
|
|
324
|
+
return false;
|
|
325
|
+
if (value.hardStop.reason !== undefined && !optionalString(value.hardStop.reason, 1000))
|
|
326
|
+
return false;
|
|
327
|
+
if (value.hardStop.scope !== undefined && !optionalString(value.hardStop.scope, 100))
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
if (value.hardConstraints === undefined)
|
|
331
|
+
return true;
|
|
332
|
+
if (!hasOnlyKeys(value.hardConstraints, WORKSPACE_CONSTRAINT_KEYS))
|
|
333
|
+
return false;
|
|
334
|
+
for (const [key, item] of Object.entries(value.hardConstraints)) {
|
|
335
|
+
if (item === null)
|
|
336
|
+
continue;
|
|
337
|
+
if (key === 'allowedCommitmentDeliveryModes' ||
|
|
338
|
+
key === 'requireAttestedAccessForDeliveryModes') {
|
|
339
|
+
if (!validStringArray(item, 5, DELIVERY_MODES))
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
else if (key === 'maxCommitmentCostUsdPerDay') {
|
|
343
|
+
if (typeof item !== 'number' || !Number.isFinite(item) || item < 0)
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
else if (key.startsWith('max')) {
|
|
347
|
+
if (!Number.isSafeInteger(item) || Number(item) < 0)
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
else if (key === 'requireApprovalRiskLevels') {
|
|
351
|
+
if (!validStringArray(item, 3, new Set(['low', 'medium', 'high'])))
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
else if (!validStringArray(item, key === 'blockedSourceKinds' ? 50 : 20))
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
function validBranch(value) {
|
|
360
|
+
return (boundedString(value, 255) &&
|
|
361
|
+
value !== 'HEAD' &&
|
|
362
|
+
!value.startsWith('refs/') &&
|
|
363
|
+
!value.startsWith('origin/') &&
|
|
364
|
+
!value.startsWith('-') &&
|
|
365
|
+
!value.startsWith('/') &&
|
|
366
|
+
!value.endsWith('/') &&
|
|
367
|
+
!value.endsWith('.') &&
|
|
368
|
+
// Control characters are exactly what this rejects: a Git ref name may not
|
|
369
|
+
// contain them, so the class is deliberate rather than an oversight.
|
|
370
|
+
// eslint-disable-next-line no-control-regex
|
|
371
|
+
!/[\s~^:?*[\\\x00-\x1f\x7f]/.test(value) &&
|
|
372
|
+
!value.includes('..') &&
|
|
373
|
+
!value.includes('@{') &&
|
|
374
|
+
!value.includes('//') &&
|
|
375
|
+
value !== '@' &&
|
|
376
|
+
!value.split('/').some((part) => part.startsWith('.') || part.endsWith('.lock')));
|
|
377
|
+
}
|
|
378
|
+
function validDelivery(value) {
|
|
379
|
+
if (!hasOnlyKeys(value, new Set(['version', 'mode', 'repo', 'baseBranch', 'expectations'])))
|
|
380
|
+
return false;
|
|
381
|
+
if (value.version !== 1 || !DELIVERY_MODES.has(String(value.mode)))
|
|
382
|
+
return false;
|
|
383
|
+
if (value.repo !== undefined &&
|
|
384
|
+
(!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(String(value.repo)) ||
|
|
385
|
+
String(value.repo) !== String(value.repo).toLowerCase()))
|
|
386
|
+
return false;
|
|
387
|
+
if (value.baseBranch !== undefined && !validBranch(value.baseBranch))
|
|
388
|
+
return false;
|
|
389
|
+
if (['draft_pr', 'push_branch', 'direct_branch'].includes(String(value.mode)) &&
|
|
390
|
+
(!value.repo || !value.baseBranch))
|
|
391
|
+
return false;
|
|
392
|
+
if (value.expectations !== undefined) {
|
|
393
|
+
if (!Array.isArray(value.expectations) || value.expectations.length > 20)
|
|
394
|
+
return false;
|
|
395
|
+
const ids = new Set();
|
|
396
|
+
const allowed = new Set([
|
|
397
|
+
'id',
|
|
398
|
+
'shape',
|
|
399
|
+
'kind',
|
|
400
|
+
'format',
|
|
401
|
+
'target',
|
|
402
|
+
'minimumAuthority',
|
|
403
|
+
'description',
|
|
404
|
+
'presetKey',
|
|
405
|
+
]);
|
|
406
|
+
for (const expectation of value.expectations) {
|
|
407
|
+
if (!hasOnlyKeys(expectation, allowed) ||
|
|
408
|
+
!['code', 'page', 'url', 'file', 'message', 'dataset'].includes(String(expectation.kind)))
|
|
409
|
+
return false;
|
|
410
|
+
if (expectation.id !== undefined) {
|
|
411
|
+
if (!boundedString(expectation.id, 64) ||
|
|
412
|
+
expectation.id === 'commitment-delivery' ||
|
|
413
|
+
ids.has(expectation.id))
|
|
414
|
+
return false;
|
|
415
|
+
ids.add(expectation.id);
|
|
416
|
+
}
|
|
417
|
+
if (expectation.shape !== undefined &&
|
|
418
|
+
!['checkable', 'judged'].includes(String(expectation.shape)))
|
|
419
|
+
return false;
|
|
420
|
+
if (expectation.minimumAuthority !== undefined &&
|
|
421
|
+
!['self_reported', 'human_confirmed', 'observation_backed'].includes(String(expectation.minimumAuthority)))
|
|
422
|
+
return false;
|
|
423
|
+
for (const [key, max] of [
|
|
424
|
+
['format', 40],
|
|
425
|
+
['target', 500],
|
|
426
|
+
['description', 500],
|
|
427
|
+
['presetKey', 64],
|
|
428
|
+
]) {
|
|
429
|
+
if (expectation[key] !== undefined && !optionalString(expectation[key], max))
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
436
|
+
function validDeliverySource(value) {
|
|
437
|
+
if (!hasOnlyKeys(value, new Set(['parentTaskId', 'branch', 'headSha', 'baseCommit', 'runtime'])))
|
|
438
|
+
return false;
|
|
439
|
+
return (typeof value.parentTaskId === 'string' &&
|
|
440
|
+
value.parentTaskId.length > 0 &&
|
|
441
|
+
value.parentTaskId.length <= 200 &&
|
|
442
|
+
typeof value.branch === 'string' &&
|
|
443
|
+
/^[A-Za-z0-9][A-Za-z0-9_./-]{0,239}$/.test(value.branch) &&
|
|
444
|
+
!value.branch.includes('..') &&
|
|
445
|
+
!value.branch.includes('@{') &&
|
|
446
|
+
/^[a-f0-9]{40,64}$/i.test(value.headSha) &&
|
|
447
|
+
typeof value.baseCommit === 'string' &&
|
|
448
|
+
/^[a-f0-9]{40,64}$/i.test(value.baseCommit) &&
|
|
449
|
+
hasOnlyKeys(value.runtime, new Set(['kind', 'id'])) &&
|
|
450
|
+
['local_daemon', 'hosted_machine'].includes(String(value.runtime.kind)) &&
|
|
451
|
+
boundedString(value.runtime.id, 200) &&
|
|
452
|
+
(value.runtime.kind !== 'hosted_machine' || value.runtime.id.startsWith('sbs_')));
|
|
453
|
+
}
|
|
454
|
+
function eventSourceRevision(event) {
|
|
455
|
+
if (!event)
|
|
456
|
+
return '';
|
|
457
|
+
const nestedCheck = event.check_run;
|
|
458
|
+
const nestedWorkflow = event.workflow_run;
|
|
459
|
+
const value = event.headSha ||
|
|
460
|
+
event.head_sha ||
|
|
461
|
+
event.sha ||
|
|
462
|
+
nestedCheck?.head_sha ||
|
|
463
|
+
nestedWorkflow?.head_sha;
|
|
464
|
+
return /^[a-f0-9]{40,64}$/i.test(String(value || '')) ? String(value).toLowerCase() : '';
|
|
465
|
+
}
|
|
466
|
+
function eventRepository(event) {
|
|
467
|
+
if (!event)
|
|
468
|
+
return '';
|
|
469
|
+
const repository = event.repository;
|
|
470
|
+
const value = event.repoFullName || repository?.full_name || repository?.fullName;
|
|
471
|
+
return /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(String(value || ''))
|
|
472
|
+
? String(value).toLowerCase()
|
|
473
|
+
: '';
|
|
474
|
+
}
|
|
475
|
+
function failedGitHubCheck(event) {
|
|
476
|
+
const eventType = String(event?.eventType || event?.type || '').toLowerCase();
|
|
477
|
+
return eventType === 'github.check_run_failed' || eventType === 'check_run_failed';
|
|
478
|
+
}
|
|
479
|
+
/** One strict parser used at storage admission and at runtime admission. */
|
|
480
|
+
function normalizeCommitmentExecutionContract(value) {
|
|
481
|
+
if (!hasOnlyKeys(value, new Set([
|
|
482
|
+
'version',
|
|
483
|
+
'kind',
|
|
484
|
+
'responsibilityRef',
|
|
485
|
+
'responsibility',
|
|
486
|
+
'event',
|
|
487
|
+
'workspace',
|
|
488
|
+
'delivery',
|
|
489
|
+
'capabilitySources',
|
|
490
|
+
'evidence',
|
|
491
|
+
'workspacePolicy',
|
|
492
|
+
'deliverySource',
|
|
493
|
+
'mustNot',
|
|
494
|
+
'return',
|
|
495
|
+
])))
|
|
496
|
+
return null;
|
|
497
|
+
const contract = value;
|
|
498
|
+
const event = contract.event === undefined ? null : contract.event;
|
|
499
|
+
const eventSha = eventSourceRevision(event);
|
|
500
|
+
const eventRepo = eventRepository(event);
|
|
501
|
+
const taskDelivery = contract.kind === 'task_delivery';
|
|
502
|
+
if (contract.version !== exports.COMMITMENT_EXECUTION_CONTRACT_VERSION ||
|
|
503
|
+
!['commitment', 'task_delivery'].includes(contract.kind) ||
|
|
504
|
+
!hasOnlyKeys(contract.responsibilityRef, new Set(['kind', 'id', 'version'])) ||
|
|
505
|
+
contract.responsibilityRef.kind !== (taskDelivery ? 'task' : 'commitment') ||
|
|
506
|
+
!boundedString(contract.responsibilityRef.id, 240) ||
|
|
507
|
+
!Number.isSafeInteger(contract.responsibilityRef.version) ||
|
|
508
|
+
contract.responsibilityRef.version < 1 ||
|
|
509
|
+
!boundedString(contract.responsibility, 2000) ||
|
|
510
|
+
!hasOnlyKeys(contract.workspace, new Set(['kind', 'base', 'fetchBase'])) ||
|
|
511
|
+
contract.workspace.kind !== 'ephemeral' ||
|
|
512
|
+
!boundedString(contract.workspace.base, 255) ||
|
|
513
|
+
(contract.workspace.fetchBase !== undefined &&
|
|
514
|
+
(contract.workspace.fetchBase !== true || contract.workspace.kind !== 'ephemeral')) ||
|
|
515
|
+
!validDelivery(contract.delivery) ||
|
|
516
|
+
!Array.isArray(contract.capabilitySources) ||
|
|
517
|
+
contract.capabilitySources.length > 32 ||
|
|
518
|
+
!contract.capabilitySources.every(validCapabilitySource) ||
|
|
519
|
+
!validWorkspacePolicy(contract.workspacePolicy ?? {}) ||
|
|
520
|
+
!(0, node_util_1.isDeepStrictEqual)(contract.mustNot, [
|
|
521
|
+
'change_workspace_administration',
|
|
522
|
+
'broaden_credentials',
|
|
523
|
+
...(taskDelivery ? ['reimplement_source_work'] : []),
|
|
524
|
+
]) ||
|
|
525
|
+
(taskDelivery
|
|
526
|
+
? contract.return !== 'task_output'
|
|
527
|
+
: contract.return !== 'commitment_result_v1') ||
|
|
528
|
+
(event !== null &&
|
|
529
|
+
(!plainObject(event) || !(0, node_util_1.isDeepStrictEqual)(event, normalizedEventFacts(event)))) ||
|
|
530
|
+
(eventSha && contract.workspace.base.toLowerCase() !== eventSha) ||
|
|
531
|
+
(eventRepo &&
|
|
532
|
+
contract.delivery.repo &&
|
|
533
|
+
String(contract.delivery.repo).toLowerCase() !== eventRepo) ||
|
|
534
|
+
(failedGitHubCheck(event) && (!eventSha || !eventRepo)) ||
|
|
535
|
+
(contract.evidence !== undefined &&
|
|
536
|
+
(taskDelivery ||
|
|
537
|
+
!validEvidence(contract.evidence) ||
|
|
538
|
+
!contract.evidence.ci.every((row) => evidenceMatchesEvent(row, event)))) ||
|
|
539
|
+
(taskDelivery &&
|
|
540
|
+
(event !== null ||
|
|
541
|
+
!['draft_pr', 'push_branch', 'direct_branch'].includes(contract.delivery.mode) ||
|
|
542
|
+
contract.workspace.kind !== 'ephemeral' ||
|
|
543
|
+
!validDeliverySource(contract.deliverySource) ||
|
|
544
|
+
contract.responsibilityRef.id !== contract.deliverySource?.parentTaskId ||
|
|
545
|
+
contract.workspace.base.toLowerCase() !==
|
|
546
|
+
String(contract.deliverySource?.baseCommit).toLowerCase())) ||
|
|
547
|
+
(!taskDelivery && contract.deliverySource !== undefined))
|
|
548
|
+
return null;
|
|
549
|
+
return JSON.parse(JSON.stringify(contract));
|
|
550
|
+
}
|
|
@@ -151,6 +151,14 @@ export declare const DAEMON_COMPUTER_EVENTS: {
|
|
|
151
151
|
* `computer_declared_services_v1`.
|
|
152
152
|
*/
|
|
153
153
|
readonly services: "daemon:computer:services";
|
|
154
|
+
/**
|
|
155
|
+
* Read the tail of the daemon's OWN process log (a bounded, redacted copy of
|
|
156
|
+
* what its logger wrote since it started), for the owner who asks why their
|
|
157
|
+
* machine reconnected. Carries a `requestId` and the principal the API
|
|
158
|
+
* authorized (`observe`); the daemon checks the principal against the grant
|
|
159
|
+
* set it holds. Needs `computer_daemon_log_v1`.
|
|
160
|
+
*/
|
|
161
|
+
readonly daemonLog: "daemon:computer:log";
|
|
154
162
|
/** The answer to any request that carried a `requestId`. */
|
|
155
163
|
readonly ack: "daemon:computer:ack";
|
|
156
164
|
readonly manifest: "daemon:computer:manifest";
|
|
@@ -295,6 +303,15 @@ export declare const COMPUTER_CAPABILITIES: {
|
|
|
295
303
|
* browser; nothing is proxied to it. Announced by the relay that serves it.
|
|
296
304
|
*/
|
|
297
305
|
readonly declaredServices: "computer_declared_services_v1";
|
|
306
|
+
/**
|
|
307
|
+
* The daemon serves the tail of its own process log
|
|
308
|
+
* (`daemon:computer:log`): an in-memory ring of lines its logger
|
|
309
|
+
* wrote, redacted before they enter the ring, read at the `watch` tier. It
|
|
310
|
+
* is NOT syslog or the journal and never reads either. Announced by the relay
|
|
311
|
+
* that serves it; a personal machine's daemon announces it too and refuses
|
|
312
|
+
* the read `consent_missing` until `skrr computer allow`.
|
|
313
|
+
*/
|
|
314
|
+
readonly daemonLog: "computer_daemon_log_v1";
|
|
298
315
|
/**
|
|
299
316
|
* The page follows the controlling window (§6.2 "a stable viewport", §7.1,
|
|
300
317
|
* OSK-13808): a browser `viewport` input, sent only by the attachment that
|
|
@@ -1080,3 +1097,54 @@ export declare function computerPowerPhaseForLeaseState(state: unknown): Compute
|
|
|
1080
1097
|
export declare function computerShowsDesktop(phase: ComputerPowerPhase): boolean;
|
|
1081
1098
|
/** Power actions are offered for a Dedicated Runtime only; a personal machine has none (§18). */
|
|
1082
1099
|
export declare function computerOffersPowerActions(machineKind: ComputerMachineKind): boolean;
|
|
1100
|
+
/**
|
|
1101
|
+
* Why the daemon's log is a wire feature at all: the tenant uid on a Dedicated
|
|
1102
|
+
* Runtime guest cannot read syslog or the journal, so an owner could not see
|
|
1103
|
+
* why their machine's daemon reconnected or failed. The daemon keeps the last
|
|
1104
|
+
* lines its OWN logger wrote in memory and serves them; it opens no file and no
|
|
1105
|
+
* system log for this.
|
|
1106
|
+
*/
|
|
1107
|
+
export declare const COMPUTER_DAEMON_LOG_LEVELS: readonly ["trace", "debug", "info", "warn", "error"];
|
|
1108
|
+
export type ComputerDaemonLogLevel = (typeof COMPUTER_DAEMON_LOG_LEVELS)[number];
|
|
1109
|
+
/** Every bound is the daemon's to enforce and the API's to validate against. */
|
|
1110
|
+
export declare const COMPUTER_DAEMON_LOG_LIMITS: {
|
|
1111
|
+
/** Lines the daemon keeps in memory; older ones fall off the front. */
|
|
1112
|
+
readonly ringLines: 2000;
|
|
1113
|
+
/** A line longer than this is cut and marked, never kept whole. */
|
|
1114
|
+
readonly lineChars: 1000;
|
|
1115
|
+
/** Lines returned when the caller names none. */
|
|
1116
|
+
readonly defaultLines: 100;
|
|
1117
|
+
/** The most lines one answer carries. */
|
|
1118
|
+
readonly maxLines: 500;
|
|
1119
|
+
/** The most bytes (UTF-8) one answer's text carries; far under the 1 MiB SSE frame. */
|
|
1120
|
+
readonly maxBytes: number;
|
|
1121
|
+
/** The longest look-back a `sinceMs` may ask for (24 h; the ring is shorter anyway). */
|
|
1122
|
+
readonly maxSinceMs: number;
|
|
1123
|
+
/** Requests the daemon answers per `rateWindowMs`; one more is `rate_limited`. */
|
|
1124
|
+
readonly rateMax: 30;
|
|
1125
|
+
readonly rateWindowMs: number;
|
|
1126
|
+
};
|
|
1127
|
+
/** One line of the daemon's log as it leaves the daemon: redacted, time and level split out. */
|
|
1128
|
+
export interface ComputerDaemonLogLine {
|
|
1129
|
+
/** Epoch milliseconds the daemon wrote it. */
|
|
1130
|
+
at: number;
|
|
1131
|
+
level: ComputerDaemonLogLevel;
|
|
1132
|
+
text: string;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* The answer to `daemon:computer:log`. `lines` are oldest first, at most
|
|
1136
|
+
* the asked number of the NEWEST that match. `truncated` is true when more
|
|
1137
|
+
* matched than were returned (by count or bytes); `ringFull` is true when the
|
|
1138
|
+
* ring has already dropped older lines, so "no line before this" does not mean
|
|
1139
|
+
* "the daemon logged nothing earlier". `startedAt` is the daemon process start:
|
|
1140
|
+
* a reconnect that restarted the daemon is visible as a new one.
|
|
1141
|
+
*/
|
|
1142
|
+
export interface ComputerDaemonLogResult {
|
|
1143
|
+
lines: ComputerDaemonLogLine[];
|
|
1144
|
+
startedAt: number;
|
|
1145
|
+
now: number;
|
|
1146
|
+
truncated: boolean;
|
|
1147
|
+
ringFull: boolean;
|
|
1148
|
+
/** Lines the redaction rewrote anywhere in the ring (a count, never content). */
|
|
1149
|
+
redactedLines: number;
|
|
1150
|
+
}
|