@skrr-ai/cli 0.1.214 → 0.1.216
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/commands/agent/message/no-reply.d.ts +4 -0
- package/dist/commands/agent/message/no-reply.js +5 -1
- package/dist/commands/agents/always-on/recovery-review.d.ts +12 -0
- package/dist/commands/agents/always-on/recovery-review.js +52 -2
- package/dist/commands/agents/permissions/list.d.ts +12 -0
- package/dist/commands/agents/permissions/list.js +42 -0
- package/dist/commands/agents/permissions/remove.d.ts +15 -0
- package/dist/commands/agents/permissions/remove.js +68 -0
- package/dist/commands/dm/work.js +2 -0
- package/dist/commands/duties/action-proposal.js +7 -1
- package/dist/commands/duties/action-proposals.d.ts +9 -0
- package/dist/commands/duties/action-proposals.js +30 -12
- package/dist/commands/duties/pause.js +20 -2
- package/dist/commands/duties/trigger-status.js +6 -1
- package/dist/commands/duties/update.js +22 -7
- package/dist/commands/tasks/ask.d.ts +3 -2
- package/dist/commands/tasks/ask.js +4 -3
- package/dist/commands/tasks/chat/exchange.d.ts +3 -2
- package/dist/commands/tasks/chat/exchange.js +18 -6
- package/dist/commands/tasks/chat/index.d.ts +11 -0
- package/dist/commands/tasks/chat/index.js +27 -0
- package/dist/commands/tasks/chat/rotate.js +5 -2
- package/dist/commands/tasks/input/answer.d.ts +12 -0
- package/dist/commands/tasks/input/answer.js +59 -5
- package/dist/commands/tasks/operations/show.js +5 -6
- package/dist/commands/tasks/result/show.js +2 -4
- package/dist/commands/tasks/retry-receipt.js +1 -3
- package/dist/commands/tasks/show.d.ts +6 -1
- package/dist/commands/tasks/show.js +19 -5
- package/dist/generated/agent-guides.json +41 -41
- package/dist/lib/compasses.d.ts +5 -0
- package/dist/lib/compasses.js +6 -1
- package/dist/lib/duties.d.ts +27 -0
- package/dist/lib/duties.js +81 -14
- package/dist/lib/permission-rules.d.ts +18 -0
- package/dist/lib/permission-rules.js +62 -0
- package/dist/lib/task-asset-upload.d.ts +7 -0
- package/dist/lib/task-asset-upload.js +114 -44
- package/dist/lib/task-extras.d.ts +19 -0
- package/dist/lib/task-extras.js +13 -0
- package/dist/lib/task-operations.d.ts +16 -0
- package/dist/lib/task-operations.js +39 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +16 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +110 -15
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/runtime.d.ts +7 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +16 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +179 -17
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/runtime.d.ts +7 -2
- package/dist/node_modules/@skrr-ai/data-provider/index.js +12697 -12082
- package/oclif.manifest.json +224 -9
- package/package.json +5 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleCovers = ruleCovers;
|
|
4
|
+
exports.ruleWhere = ruleWhere;
|
|
5
|
+
exports.ruleGranted = ruleGranted;
|
|
6
|
+
exports.ruleUse = ruleUse;
|
|
7
|
+
exports.ruleLines = ruleLines;
|
|
8
|
+
exports.ruleOutcomeLine = ruleOutcomeLine;
|
|
9
|
+
/** What a rule covers. "any command" is worded here, never read from a stored label. */
|
|
10
|
+
function ruleCovers(rule) {
|
|
11
|
+
return rule.match?.kind === 'any' ? 'any command' : rule.label;
|
|
12
|
+
}
|
|
13
|
+
function ruleWhere(rule) {
|
|
14
|
+
if (rule.where?.kind === 'machine') {
|
|
15
|
+
return rule.where.harnessId ? `on machine ${rule.where.harnessId}` : 'on a machine';
|
|
16
|
+
}
|
|
17
|
+
return 'in the cloud';
|
|
18
|
+
}
|
|
19
|
+
function ruleGranted(rule) {
|
|
20
|
+
const at = rule.createdAt ? `granted ${rule.createdAt}` : 'granted';
|
|
21
|
+
if (rule.source?.taskId)
|
|
22
|
+
return `${at} from Task ${rule.source.taskId}`;
|
|
23
|
+
if (rule.source?.conversationId)
|
|
24
|
+
return `${at} from chat ${rule.source.conversationId}`;
|
|
25
|
+
return at;
|
|
26
|
+
}
|
|
27
|
+
function ruleUse(rule) {
|
|
28
|
+
const count = rule.useCount ?? 0;
|
|
29
|
+
if (count === 0)
|
|
30
|
+
return 'not used yet';
|
|
31
|
+
const times = count === 1 ? 'used once' : `used ${count} times`;
|
|
32
|
+
return rule.lastUsedAt ? `${times}, last ${rule.lastUsedAt}` : times;
|
|
33
|
+
}
|
|
34
|
+
/** One rule as a short block: what it covers, then its id and details. */
|
|
35
|
+
function ruleLines(rule) {
|
|
36
|
+
return [
|
|
37
|
+
`${ruleCovers(rule)} (${rule.tool})`,
|
|
38
|
+
` id: ${rule.id}`,
|
|
39
|
+
` ${ruleWhere(rule)}; ${ruleGranted(rule)}`,
|
|
40
|
+
` ${ruleUse(rule)}`,
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
/** Why an "Always allow" saved no rule. Every one says the call itself was still allowed. */
|
|
44
|
+
const REFUSAL_LINES = {
|
|
45
|
+
invalid_context: 'Allowed this once. The rule could not be saved, so the Agent asks again next time.',
|
|
46
|
+
unavailable: 'Allowed this once. The rule could not be saved, so the Agent asks again next time.',
|
|
47
|
+
unsupported_place: 'Allowed this once. Rules are not available where this Agent runs yet, so it asks again next time.',
|
|
48
|
+
not_owner: "Allowed this once. Only the Agent's owner can save a rule, so it asks again next time.",
|
|
49
|
+
option_unavailable: 'Allowed this once. That rule no longer fits this call, so the Agent asks again next time.',
|
|
50
|
+
too_many_rules: 'Allowed this once. This Agent already holds as many rules as it can: remove one with `skrr agents permissions remove`.',
|
|
51
|
+
not_interactive: 'Allowed this once. A rule is saved only when you choose it on the card in the app, so the Agent asks again next time.',
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* What came of "Always allow …" chosen on a parked Task approval, as one line. The web card says
|
|
55
|
+
* the same through its toast.
|
|
56
|
+
*/
|
|
57
|
+
function ruleOutcomeLine(outcome) {
|
|
58
|
+
if (!outcome.granted)
|
|
59
|
+
return REFUSAL_LINES[outcome.reason];
|
|
60
|
+
const covers = outcome.breadth === 'any' ? 'any command' : outcome.label;
|
|
61
|
+
return `Saved a rule for ${covers}: the Agent runs calls it covers without asking you. See or remove it with \`skrr agents permissions list <agent>\`.`;
|
|
62
|
+
}
|
|
@@ -35,6 +35,13 @@ export interface UploadedTaskAsset {
|
|
|
35
35
|
* local file, which is a different version for any canonicalized image.
|
|
36
36
|
*/
|
|
37
37
|
digest?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The name and type the server STORED, as `tasks attachments list` shows them. The server
|
|
40
|
+
* decides both from the bytes: PNG bytes named `shot.tsx` are kept as `shot.png`, `image/png`,
|
|
41
|
+
* and a component file whose first markup is an `<svg>` is kept as `text/plain`. Only a
|
|
42
|
+
* response that names neither falls back to the local name and the type guessed from its
|
|
43
|
+
* extension; a ready attachment row always names both (OSK-33381).
|
|
44
|
+
*/
|
|
38
45
|
filename: string;
|
|
39
46
|
mimeType: string;
|
|
40
47
|
/** True when the server returned an existing row for the same sha256. */
|
|
@@ -62,7 +62,9 @@ exports.postFileToStorage = postFileToStorage;
|
|
|
62
62
|
* evidence reference that named the local hash would pin a version of the
|
|
63
63
|
* file that was never stored (OSK-10120). The local hash is computed only
|
|
64
64
|
* where the protocol needs it — declaring a direct upload, which storage then
|
|
65
|
-
* enforces — and never leaves this module as a claim about the asset.
|
|
65
|
+
* enforces — and never leaves this module as a claim about the asset. The
|
|
66
|
+
* name and MIME type it reports are the server's for the same reason: the
|
|
67
|
+
* server decides them from the bytes, not from the extension (OSK-33381).
|
|
66
68
|
*/
|
|
67
69
|
const fs = __importStar(require("node:fs"));
|
|
68
70
|
const http = __importStar(require("node:http"));
|
|
@@ -86,6 +88,9 @@ function storedDigest(asset) {
|
|
|
86
88
|
const value = asset.contentSha256;
|
|
87
89
|
return typeof value === 'string' && SHA256_HEX.test(value) ? value.toLowerCase() : undefined;
|
|
88
90
|
}
|
|
91
|
+
function storedText(value) {
|
|
92
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
93
|
+
}
|
|
89
94
|
/**
|
|
90
95
|
* Read the Task an upload targets, through the same credential the upload
|
|
91
96
|
* will use. In a session the task comes from the claim, so the read is the
|
|
@@ -106,8 +111,10 @@ async function readTaskForUpload(taskId) {
|
|
|
106
111
|
async function uploadTaskAssetFile(opts) {
|
|
107
112
|
const { taskId, filePath, role, ledger } = opts;
|
|
108
113
|
if (opts.resumeAttachmentId !== undefined &&
|
|
109
|
-
(!opts.resumeAttachmentId ||
|
|
110
|
-
opts.resumeAttachmentId.
|
|
114
|
+
(!opts.resumeAttachmentId ||
|
|
115
|
+
opts.resumeAttachmentId.trim() !== opts.resumeAttachmentId ||
|
|
116
|
+
opts.resumeAttachmentId.length > 200 ||
|
|
117
|
+
ledger !== undefined)) {
|
|
111
118
|
throw new Error('Resume requires one exact attachment id and retains its original ledger declaration.');
|
|
112
119
|
}
|
|
113
120
|
if (!fs.existsSync(filePath)) {
|
|
@@ -132,8 +139,7 @@ async function uploadTaskAssetFile(opts) {
|
|
|
132
139
|
let result;
|
|
133
140
|
try {
|
|
134
141
|
if (opts.resumeAttachmentId !== undefined) {
|
|
135
|
-
result = await resumeDirectUpload({ taskId, filePath, size, filename, mimeType, role,
|
|
136
|
-
attachmentId: opts.resumeAttachmentId }, sessionTarget);
|
|
142
|
+
result = await resumeDirectUpload({ taskId, filePath, size, filename, mimeType, role, attachmentId: opts.resumeAttachmentId }, sessionTarget);
|
|
137
143
|
}
|
|
138
144
|
else if (sessionTarget) {
|
|
139
145
|
result = direct
|
|
@@ -154,8 +160,8 @@ async function uploadTaskAssetFile(opts) {
|
|
|
154
160
|
status: 'ready',
|
|
155
161
|
id: String(result.id ?? result._id),
|
|
156
162
|
digest: storedDigest(result),
|
|
157
|
-
filename,
|
|
158
|
-
mimeType,
|
|
163
|
+
filename: storedText(result.originalName) ?? filename,
|
|
164
|
+
mimeType: storedText(result.mimeType) ?? mimeType,
|
|
159
165
|
deduplicated: result.deduplicated === true,
|
|
160
166
|
...(result.resourceReceipt ? { resourceReceipt: result.resourceReceipt } : {}),
|
|
161
167
|
};
|
|
@@ -315,13 +321,19 @@ function directUploadProtocol(taskId, attachmentId, target) {
|
|
|
315
321
|
credential: target.credential,
|
|
316
322
|
}),
|
|
317
323
|
sign: (partNumbers) => (0, api_fetch_1.apiFetch)(`${uploadPath}/upload-parts/sign`, {
|
|
318
|
-
method: 'POST',
|
|
324
|
+
method: 'POST',
|
|
325
|
+
credential: target.credential,
|
|
326
|
+
body: { partNumbers },
|
|
319
327
|
}),
|
|
320
328
|
record: (part) => (0, api_fetch_1.apiFetch)(`${uploadPath}/upload-parts/complete`, {
|
|
321
|
-
method: 'POST',
|
|
329
|
+
method: 'POST',
|
|
330
|
+
credential: target.credential,
|
|
331
|
+
body: part,
|
|
322
332
|
}),
|
|
323
333
|
complete: () => (0, api_fetch_1.apiFetch)(`${target.path}/complete`, {
|
|
324
|
-
method: 'POST',
|
|
334
|
+
method: 'POST',
|
|
335
|
+
credential: target.credential,
|
|
336
|
+
body: { attachmentId },
|
|
325
337
|
}),
|
|
326
338
|
};
|
|
327
339
|
}
|
|
@@ -330,40 +342,59 @@ function taskAssetUploadRecovery(error) {
|
|
|
330
342
|
if (!error || typeof error !== 'object')
|
|
331
343
|
return undefined;
|
|
332
344
|
const value = error.uploadRecovery;
|
|
333
|
-
if (!value ||
|
|
345
|
+
if (!value ||
|
|
346
|
+
typeof value.taskId !== 'string' ||
|
|
347
|
+
typeof value.attachmentId !== 'string' ||
|
|
334
348
|
value.transport !== 'multipart')
|
|
335
349
|
return undefined;
|
|
336
|
-
return {
|
|
337
|
-
|
|
350
|
+
return {
|
|
351
|
+
taskId: value.taskId,
|
|
352
|
+
attachmentId: value.attachmentId,
|
|
353
|
+
transport: 'multipart',
|
|
354
|
+
...(typeof value.sessionId === 'string' ? { sessionId: value.sessionId } : {}),
|
|
355
|
+
};
|
|
338
356
|
}
|
|
339
357
|
function resumeHint(attachmentId) {
|
|
340
|
-
return `Upload attachment ${attachmentId} is not confirmed complete. ` +
|
|
341
|
-
`Use --resume-attachment ${attachmentId} with tasks attachments upload and the same file to recover this exact upload
|
|
358
|
+
return (`Upload attachment ${attachmentId} is not confirmed complete. ` +
|
|
359
|
+
`Use --resume-attachment ${attachmentId} with tasks attachments upload and the same file to recover this exact upload.`);
|
|
342
360
|
}
|
|
343
361
|
async function resumeDirectUpload(file, target) {
|
|
344
362
|
const taskId = target?.taskId ?? file.taskId;
|
|
345
363
|
const protocol = directUploadProtocol(taskId, file.attachmentId, target);
|
|
346
364
|
const progress = await protocol.status();
|
|
347
|
-
const rawDeclaration = progress
|
|
365
|
+
const rawDeclaration = progress
|
|
366
|
+
?.declaredAttachment;
|
|
348
367
|
const declaration = rawDeclaration && typeof rawDeclaration === 'object' && !Array.isArray(rawDeclaration)
|
|
349
|
-
? rawDeclaration
|
|
368
|
+
? rawDeclaration
|
|
369
|
+
: undefined;
|
|
350
370
|
const sha256 = await sha256OfFile(file.filePath);
|
|
351
|
-
if (!declaration ||
|
|
352
|
-
|
|
353
|
-
declaration.
|
|
354
|
-
declaration.
|
|
355
|
-
|
|
371
|
+
if (!declaration ||
|
|
372
|
+
file.size < 1 ||
|
|
373
|
+
declaration.basis !== 'declared_upload_intent' ||
|
|
374
|
+
declaration.attachmentId !== file.attachmentId ||
|
|
375
|
+
declaration.taskId !== taskId ||
|
|
376
|
+
declaration.filename !== file.filename ||
|
|
377
|
+
declaration.mimeType !== file.mimeType ||
|
|
378
|
+
declaration.sizeBytes !== file.size ||
|
|
379
|
+
declaration.sha256 !== sha256 ||
|
|
380
|
+
typeof declaration.role !== 'string' ||
|
|
381
|
+
!['input', 'evidence', 'deliverable'].includes(declaration.role) ||
|
|
356
382
|
(file.role !== undefined && declaration.role !== file.role)) {
|
|
357
383
|
throw new Error('This file does not match the existing upload declaration, or the server cannot verify it. No replacement upload was created.');
|
|
358
384
|
}
|
|
359
|
-
if (progress.transport !== 'multipart' ||
|
|
385
|
+
if (progress.transport !== 'multipart' ||
|
|
386
|
+
typeof progress.expiresAt !== 'string' ||
|
|
360
387
|
!Number.isFinite(Date.parse(progress.expiresAt)) ||
|
|
361
388
|
Date.parse(progress.expiresAt) <= Date.now()) {
|
|
362
389
|
throw new Error('Only an unexpired multipart upload can be resumed. No replacement upload was created.');
|
|
363
390
|
}
|
|
364
391
|
const intent = {
|
|
365
|
-
attachment: { id: file.attachmentId, status: 'pending' },
|
|
366
|
-
|
|
392
|
+
attachment: { id: file.attachmentId, status: 'pending' },
|
|
393
|
+
uploadUrl: null,
|
|
394
|
+
uploadFields: null,
|
|
395
|
+
uploadTransport: 'multipart',
|
|
396
|
+
partSize: progress.partSize,
|
|
397
|
+
partCount: progress.expectedParts,
|
|
367
398
|
};
|
|
368
399
|
// Even a ready session goes through canonical completion to recover its
|
|
369
400
|
// verified attachment and original ledger receipt, never its declaration.
|
|
@@ -382,7 +413,8 @@ async function uploadDirectIntent(file, intent, protocol) {
|
|
|
382
413
|
if (intent.attachment.status === 'ready')
|
|
383
414
|
return intent.attachment;
|
|
384
415
|
if ((intent.attachment.status !== undefined && intent.attachment.status !== 'pending') ||
|
|
385
|
-
(intent.uploadTransport !== undefined &&
|
|
416
|
+
(intent.uploadTransport !== undefined &&
|
|
417
|
+
!['single', 'multipart'].includes(intent.uploadTransport))) {
|
|
386
418
|
throw new Error('The server returned an unusable Task attachment upload intent.');
|
|
387
419
|
}
|
|
388
420
|
try {
|
|
@@ -393,7 +425,11 @@ async function uploadDirectIntent(file, intent, protocol) {
|
|
|
393
425
|
if (!intent.uploadUrl || !intent.uploadFields) {
|
|
394
426
|
throw new Error('The pending Task attachment has no usable storage grant; it was not uploaded.');
|
|
395
427
|
}
|
|
396
|
-
await postFileToStorage({
|
|
428
|
+
await postFileToStorage({
|
|
429
|
+
...file,
|
|
430
|
+
uploadUrl: intent.uploadUrl,
|
|
431
|
+
uploadFields: intent.uploadFields,
|
|
432
|
+
});
|
|
397
433
|
}
|
|
398
434
|
const completed = await protocol.complete();
|
|
399
435
|
requireReadyAsset(completed);
|
|
@@ -423,19 +459,35 @@ async function uploadMultipartFile(file, intent, protocol) {
|
|
|
423
459
|
const lengthOf = (partNumber) => Math.min(partSize, file.size - (partNumber - 1) * partSize);
|
|
424
460
|
let sessionId;
|
|
425
461
|
const inspect = (progress) => {
|
|
426
|
-
if (!progress ||
|
|
427
|
-
|
|
428
|
-
progress.
|
|
429
|
-
progress.
|
|
430
|
-
|
|
462
|
+
if (!progress ||
|
|
463
|
+
typeof progress.sessionId !== 'string' ||
|
|
464
|
+
!progress.sessionId ||
|
|
465
|
+
(sessionId && progress.sessionId !== sessionId) ||
|
|
466
|
+
progress.transport !== 'multipart' ||
|
|
467
|
+
progress.partSize !== partSize ||
|
|
468
|
+
progress.expectedSize !== file.size ||
|
|
469
|
+
progress.expectedParts !== partCount ||
|
|
470
|
+
!Array.isArray(progress.receivedParts) ||
|
|
471
|
+
![
|
|
472
|
+
'created',
|
|
473
|
+
'receiving',
|
|
474
|
+
'landed',
|
|
475
|
+
'verified',
|
|
476
|
+
'scanning',
|
|
477
|
+
'canonicalizing',
|
|
478
|
+
'ready',
|
|
479
|
+
].includes(progress.state)) {
|
|
431
480
|
throw new Error('The server returned inconsistent multipart upload progress.');
|
|
432
481
|
}
|
|
433
482
|
sessionId = progress.sessionId;
|
|
434
483
|
const received = new Set();
|
|
435
484
|
let bytes = 0;
|
|
436
485
|
for (const part of progress.receivedParts) {
|
|
437
|
-
if (!Number.isInteger(part.partNumber) ||
|
|
438
|
-
|
|
486
|
+
if (!Number.isInteger(part.partNumber) ||
|
|
487
|
+
part.partNumber < 1 ||
|
|
488
|
+
part.partNumber > partCount ||
|
|
489
|
+
received.has(part.partNumber) ||
|
|
490
|
+
part.byteLength !== lengthOf(part.partNumber)) {
|
|
439
491
|
throw new Error('The server returned an invalid multipart part receipt.');
|
|
440
492
|
}
|
|
441
493
|
received.add(part.partNumber);
|
|
@@ -457,13 +509,18 @@ async function uploadMultipartFile(file, intent, protocol) {
|
|
|
457
509
|
}
|
|
458
510
|
const signed = await protocol.sign([partNumber]);
|
|
459
511
|
inspect(signed?.progress);
|
|
460
|
-
if (signed.sessionId !== sessionId ||
|
|
461
|
-
|
|
512
|
+
if (signed.sessionId !== sessionId ||
|
|
513
|
+
!Array.isArray(signed.parts) ||
|
|
514
|
+
signed.parts.length !== 1 ||
|
|
515
|
+
signed.parts[0].partNumber !== partNumber ||
|
|
516
|
+
typeof signed.parts[0].url !== 'string') {
|
|
462
517
|
throw new Error('The server did not grant the requested multipart part.');
|
|
463
518
|
}
|
|
464
519
|
const receipt = await putFilePartToStorage({
|
|
465
|
-
uploadUrl: signed.parts[0].url,
|
|
466
|
-
|
|
520
|
+
uploadUrl: signed.parts[0].url,
|
|
521
|
+
filePath: file.filePath,
|
|
522
|
+
offset: (partNumber - 1) * partSize,
|
|
523
|
+
byteLength: lengthOf(partNumber),
|
|
467
524
|
});
|
|
468
525
|
const recorded = await protocol.record({ partNumber, ...receipt });
|
|
469
526
|
const landed = inspect(recorded?.progress);
|
|
@@ -473,7 +530,8 @@ async function uploadMultipartFile(file, intent, protocol) {
|
|
|
473
530
|
progress = recorded.progress;
|
|
474
531
|
}
|
|
475
532
|
const final = await protocol.status();
|
|
476
|
-
if (inspect(final).size !== partCount ||
|
|
533
|
+
if (inspect(final).size !== partCount ||
|
|
534
|
+
final.uploadedBytes !== file.size ||
|
|
477
535
|
fs.statSync(file.filePath).size !== file.size) {
|
|
478
536
|
throw new Error('The multipart upload is incomplete or the file changed during upload.');
|
|
479
537
|
}
|
|
@@ -488,7 +546,10 @@ async function putFilePartToStorage(p) {
|
|
|
488
546
|
let sent = 0;
|
|
489
547
|
let ended = false;
|
|
490
548
|
let etag;
|
|
491
|
-
const stream = fs.createReadStream(p.filePath, {
|
|
549
|
+
const stream = fs.createReadStream(p.filePath, {
|
|
550
|
+
start: p.offset,
|
|
551
|
+
end: p.offset + p.byteLength - 1,
|
|
552
|
+
});
|
|
492
553
|
const fail = (message) => {
|
|
493
554
|
if (settled)
|
|
494
555
|
return;
|
|
@@ -506,7 +567,8 @@ async function putFilePartToStorage(p) {
|
|
|
506
567
|
resolve({ etag, byteLength: sent });
|
|
507
568
|
};
|
|
508
569
|
const req = (url.protocol === 'http:' ? http : https).request(url, {
|
|
509
|
-
method: 'PUT',
|
|
570
|
+
method: 'PUT',
|
|
571
|
+
headers: { 'Content-Length': String(p.byteLength) },
|
|
510
572
|
}, (res) => {
|
|
511
573
|
const status = res.statusCode ?? 0;
|
|
512
574
|
const actualEtag = res.headers.etag;
|
|
@@ -517,14 +579,22 @@ async function putFilePartToStorage(p) {
|
|
|
517
579
|
}
|
|
518
580
|
res.on('error', () => fail('Storage multipart response failed.'));
|
|
519
581
|
res.on('aborted', () => fail('Storage multipart response was interrupted.'));
|
|
520
|
-
res.on('end', () => {
|
|
582
|
+
res.on('end', () => {
|
|
583
|
+
etag = actualEtag;
|
|
584
|
+
done();
|
|
585
|
+
});
|
|
521
586
|
res.resume();
|
|
522
587
|
});
|
|
523
588
|
req.on('error', () => fail('Storage multipart upload failed.'));
|
|
524
589
|
req.setTimeout(60000, () => fail('Storage multipart upload timed out.'));
|
|
525
|
-
stream.on('data', (chunk) => {
|
|
590
|
+
stream.on('data', (chunk) => {
|
|
591
|
+
sent += chunk.length;
|
|
592
|
+
});
|
|
526
593
|
stream.on('error', () => fail('The multipart file could not be read.'));
|
|
527
|
-
stream.on('end', () => {
|
|
594
|
+
stream.on('end', () => {
|
|
595
|
+
ended = true;
|
|
596
|
+
done();
|
|
597
|
+
});
|
|
528
598
|
stream.pipe(req);
|
|
529
599
|
});
|
|
530
600
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TaskResultRecord } from '@skrr-ai/data-provider';
|
|
1
2
|
import { withQuery } from './triggers';
|
|
2
3
|
type Query = Parameters<typeof withQuery>[1];
|
|
3
4
|
type Json = Record<string, unknown>;
|
|
@@ -161,4 +162,22 @@ export interface TaskLabelSuggestionResponse {
|
|
|
161
162
|
suggestions?: TaskLabelSuggestion[];
|
|
162
163
|
}
|
|
163
164
|
export declare function taskLabelSuggestion(taskId: string): Promise<TaskLabelSuggestionResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* The one Space evidence scope an exact Result read may name. The route refuses
|
|
167
|
+
* both at once, and a bound Space review or Notebook session must name its own.
|
|
168
|
+
*/
|
|
169
|
+
export type ExactTaskResultScope = {
|
|
170
|
+
reviewSpaceId?: string;
|
|
171
|
+
notebookSpaceId?: string;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* `GET /api/tasks/:taskId/results/:resultId` — one immutable Result version, read
|
|
175
|
+
* by id (`skrr tasks result show --result <id>`, OSK-32828).
|
|
176
|
+
*
|
|
177
|
+
* Through the shared fetch rather than `request.get`: a native Space review
|
|
178
|
+
* session proves itself with the runtime headers that fetch attaches, and only
|
|
179
|
+
* for this exact path and its single `reviewSpaceId` (lib/task-runtime-headers.ts).
|
|
180
|
+
* Kept in the lib so `domain-api-parity` sees the endpoint.
|
|
181
|
+
*/
|
|
182
|
+
export declare function readExactTaskResult(taskId: string, resultId: string, scope?: ExactTaskResultScope): Promise<TaskResultRecord>;
|
|
164
183
|
export {};
|
package/dist/lib/task-extras.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.taskRunFork = taskRunFork;
|
|
|
7
7
|
exports.taskRunPromote = taskRunPromote;
|
|
8
8
|
exports.parseExecutionTargetRef = parseExecutionTargetRef;
|
|
9
9
|
exports.taskLabelSuggestion = taskLabelSuggestion;
|
|
10
|
+
exports.readExactTaskResult = readExactTaskResult;
|
|
10
11
|
/**
|
|
11
12
|
* task-extras.ts — the `/api/tasks` endpoints that have no `dataService.*`
|
|
12
13
|
* wrapper, gathered so every one of them is reachable from `skrr`.
|
|
@@ -198,3 +199,15 @@ function taskLabelSuggestion(taskId) {
|
|
|
198
199
|
method: 'POST',
|
|
199
200
|
});
|
|
200
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* `GET /api/tasks/:taskId/results/:resultId` — one immutable Result version, read
|
|
204
|
+
* by id (`skrr tasks result show --result <id>`, OSK-32828).
|
|
205
|
+
*
|
|
206
|
+
* Through the shared fetch rather than `request.get`: a native Space review
|
|
207
|
+
* session proves itself with the runtime headers that fetch attaches, and only
|
|
208
|
+
* for this exact path and its single `reviewSpaceId` (lib/task-runtime-headers.ts).
|
|
209
|
+
* Kept in the lib so `domain-api-parity` sees the endpoint.
|
|
210
|
+
*/
|
|
211
|
+
function readExactTaskResult(taskId, resultId, scope = {}) {
|
|
212
|
+
return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)(`${base(taskId)}/results/${encodeURIComponent(resultId)}`, scope));
|
|
213
|
+
}
|
|
@@ -30,6 +30,22 @@ type TaskActionContext = {
|
|
|
30
30
|
* `assignTaskRemedies`), so a renderer lists every entry, not only the first.
|
|
31
31
|
*/
|
|
32
32
|
export declare function taskActionRemedies(action: string, taskId: string, targetId: string | undefined, bin?: string, context?: TaskActionContext): TaskActionRemedy[];
|
|
33
|
+
/**
|
|
34
|
+
* The commands that settle a submitted Result waiting on a Review (`review_required`).
|
|
35
|
+
*
|
|
36
|
+
* The server offers `complete_task` and `request_changes` there, and neither maps through the
|
|
37
|
+
* table above. `request_changes` targets the Task, while `tasks review` needs the exact Result
|
|
38
|
+
* (`--result-id`), so the table leaves it unmapped; and `tasks complete` submits a NEW Result,
|
|
39
|
+
* where this one only needs closing. A caller that holds the Task passes its `currentResultId`,
|
|
40
|
+
* and gets the Review itself plus, when the server offers closing, the owner's close past it
|
|
41
|
+
* (OSK-33352).
|
|
42
|
+
*
|
|
43
|
+
* Accepting closes the Task. Its submitter cannot accept it (`TASK_REVIEW_SELF_ACCEPTANCE`), and a
|
|
44
|
+
* Task that requires the Review closes without one only for its owner, so each says who it is for.
|
|
45
|
+
*/
|
|
46
|
+
export declare function reviewDecisionRemedies(taskId: string, resultId: string | undefined, bin?: string, options?: {
|
|
47
|
+
closable?: boolean;
|
|
48
|
+
}): TaskActionRemedy[];
|
|
33
49
|
/** One row per remedy: the command, then what it does, with the notes lined up. */
|
|
34
50
|
export declare function taskActionRemedyRows(remedies: readonly TaskActionRemedy[]): string[];
|
|
35
51
|
/** The first command for an action. A renderer should list `taskActionRemedies` instead. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.taskActionRemedies = taskActionRemedies;
|
|
4
|
+
exports.reviewDecisionRemedies = reviewDecisionRemedies;
|
|
4
5
|
exports.taskActionRemedyRows = taskActionRemedyRows;
|
|
5
6
|
exports.taskActionCommand = taskActionCommand;
|
|
6
7
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
@@ -52,6 +53,44 @@ function taskActionRemedies(action, taskId, targetId, bin = 'skrr', context = {}
|
|
|
52
53
|
};
|
|
53
54
|
return commands[action] ? [{ command: `${bin} ${commands[action]}` }] : [];
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The commands that settle a submitted Result waiting on a Review (`review_required`).
|
|
58
|
+
*
|
|
59
|
+
* The server offers `complete_task` and `request_changes` there, and neither maps through the
|
|
60
|
+
* table above. `request_changes` targets the Task, while `tasks review` needs the exact Result
|
|
61
|
+
* (`--result-id`), so the table leaves it unmapped; and `tasks complete` submits a NEW Result,
|
|
62
|
+
* where this one only needs closing. A caller that holds the Task passes its `currentResultId`,
|
|
63
|
+
* and gets the Review itself plus, when the server offers closing, the owner's close past it
|
|
64
|
+
* (OSK-33352).
|
|
65
|
+
*
|
|
66
|
+
* Accepting closes the Task. Its submitter cannot accept it (`TASK_REVIEW_SELF_ACCEPTANCE`), and a
|
|
67
|
+
* Task that requires the Review closes without one only for its owner, so each says who it is for.
|
|
68
|
+
*/
|
|
69
|
+
function reviewDecisionRemedies(taskId, resultId, bin = 'skrr', options = {}) {
|
|
70
|
+
const task = (0, shell_quote_1.shellQuoteArg)(taskId);
|
|
71
|
+
const result = resultId ? (0, shell_quote_1.shellQuoteArg)(resultId) : '<result-id>';
|
|
72
|
+
const review = `${bin} tasks review ${task} --result-id ${result}`;
|
|
73
|
+
// `--rationale` is named in the note rather than the command: a quoted placeholder would make that
|
|
74
|
+
// command the widest by far, and the aligned notes would pad every other row out to it.
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
command: `${review} --decision accepted`,
|
|
78
|
+
what: 'accept it and close the Task (not its submitter)',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
command: `${review} --decision changes_requested`,
|
|
82
|
+
what: 'request changes (say what with --rationale)',
|
|
83
|
+
},
|
|
84
|
+
...(options.closable
|
|
85
|
+
? [
|
|
86
|
+
{
|
|
87
|
+
command: `${bin} tasks move ${task} --status done`,
|
|
88
|
+
what: 'its owner closes it without a Review',
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
: []),
|
|
92
|
+
];
|
|
93
|
+
}
|
|
55
94
|
/** One row per remedy: the command, then what it does, with the notes lined up. */
|
|
56
95
|
function taskActionRemedyRows(remedies) {
|
|
57
96
|
const width = Math.max(0, ...remedies.filter((r) => r.what).map((r) => r.command.length));
|
|
@@ -17,10 +17,21 @@ interface LockAcquireState {
|
|
|
17
17
|
mkdirCalls: number;
|
|
18
18
|
/** When it started, which is when its deadline started. */
|
|
19
19
|
startedAt: number;
|
|
20
|
+
/** Set once it took the lock and its holder began releasing it (OSK-33430). */
|
|
21
|
+
releasing: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Set when that release passed its bound with an `rmdir` or `utimes` still
|
|
24
|
+
* pending. Unlike `abandoned`, it refuses no call and replaces no answer
|
|
25
|
+
* (EABANDONED delivered to proper-lockfile's mtime-refresh `stat` callback
|
|
26
|
+
* throws in a timer; see `trackedLockFs`). It only keeps this release a
|
|
27
|
+
* blocker.
|
|
28
|
+
*/
|
|
29
|
+
releaseTimedOut: boolean;
|
|
20
30
|
}
|
|
21
31
|
export declare const __authLockTesting: {
|
|
22
32
|
acquireDeadlineMs: number;
|
|
23
33
|
asyncFsProbeMs: number;
|
|
34
|
+
releaseDeadlineMs: number;
|
|
24
35
|
/**
|
|
25
36
|
* The `fs` proper-lockfile uses: Node's own. Its default, graceful-fs 4.2,
|
|
26
37
|
* retries EMFILE only for open, readFile, writeFile, appendFile, copyFile and
|
|
@@ -129,13 +140,16 @@ export declare function installLockExitHandlers(options?: LockExitHandlerOptions
|
|
|
129
140
|
* Acquire the cross-process auth lock, run the body, release on `finally`.
|
|
130
141
|
* Throws ELOCKED once proper-lockfile's retries are spent (about 19 s), and a
|
|
131
142
|
* `TransientAuthFailure` if the acquire is still pending at
|
|
132
|
-
* `LOCK_ACQUIRE_DEADLINE_MS` (OSK-33422).
|
|
143
|
+
* `LOCK_ACQUIRE_DEADLINE_MS` (OSK-33422). Returns the body's result once the
|
|
144
|
+
* release has answered or waited `LOCK_RELEASE_DEADLINE_MS` (OSK-33430).
|
|
133
145
|
*
|
|
134
146
|
* We lock a sentinel file (auth.lock) that we create/touch if missing —
|
|
135
147
|
* locking the real auth.json would race with atomic-rename writes.
|
|
136
148
|
*
|
|
137
149
|
* @param daemonId When supplied, lock-lifecycle telemetry events are emitted:
|
|
138
|
-
* refresh_lock_acquiring, refresh_lock_acquired, refresh_lock_released
|
|
150
|
+
* refresh_lock_acquiring, refresh_lock_acquired, then refresh_lock_released
|
|
151
|
+
* once the release answers, or refresh_lock_release_timeout when it does not
|
|
152
|
+
* answer in time.
|
|
139
153
|
*/
|
|
140
154
|
export declare function withAuthLock<T>(body: () => Promise<T>, daemonId?: string): Promise<T>;
|
|
141
155
|
/**
|