@skrr-ai/cli 0.1.155 → 0.1.158
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.js +64 -16
- package/dist/commands/activity/list.d.ts +13 -0
- package/dist/commands/activity/list.js +50 -0
- package/dist/commands/activity/scan-older.d.ts +23 -0
- package/dist/commands/activity/scan-older.js +74 -0
- package/dist/commands/activity/show.d.ts +27 -0
- package/dist/commands/activity/show.js +228 -0
- package/dist/commands/agent/message/send.js +64 -19
- package/dist/commands/agents/always-on/held-messages.js +24 -1
- package/dist/commands/agents/always-on/status.js +6 -1
- package/dist/commands/agents/mini-computer/app/reset.d.ts +13 -0
- package/dist/commands/agents/mini-computer/app/reset.js +35 -0
- package/dist/commands/agents/mini-computer/app/set.d.ts +16 -0
- package/dist/commands/agents/mini-computer/app/set.js +70 -0
- package/dist/commands/agents/mini-computer/layout/change.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/change.js +44 -0
- package/dist/commands/agents/mini-computer/layout/folder.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/folder.js +35 -0
- package/dist/commands/agents/mini-computer/layout/move.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/move.js +32 -0
- package/dist/commands/agents/mini-computer/layout/pin.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/pin.js +35 -0
- package/dist/commands/agents/mini-computer/layout/remove.d.ts +13 -0
- package/dist/commands/agents/mini-computer/layout/remove.js +27 -0
- package/dist/commands/agents/mini-computer/layout/restore.d.ts +13 -0
- package/dist/commands/agents/mini-computer/layout/restore.js +27 -0
- package/dist/commands/agents/mini-computer/layout/unfolder.d.ts +13 -0
- package/dist/commands/agents/mini-computer/layout/unfolder.js +27 -0
- package/dist/commands/agents/mini-computer/layout/unpin.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/unpin.js +34 -0
- package/dist/commands/agents/mini-computer/show.d.ts +13 -0
- package/dist/commands/agents/mini-computer/show.js +60 -0
- package/dist/commands/agents/mini-computer/tasks-view.d.ts +29 -0
- package/dist/commands/agents/mini-computer/tasks-view.js +100 -0
- package/dist/commands/apps/auto-apply.d.ts +14 -0
- package/dist/commands/apps/auto-apply.js +53 -0
- package/dist/commands/apps/check.js +4 -1
- package/dist/commands/apps/create.js +11 -6
- package/dist/commands/apps/data/batch.d.ts +15 -0
- package/dist/commands/apps/data/batch.js +59 -0
- package/dist/commands/apps/data/collections.d.ts +12 -0
- package/dist/commands/apps/data/collections.js +44 -0
- package/dist/commands/apps/data/delete.d.ts +15 -0
- package/dist/commands/apps/data/delete.js +57 -0
- package/dist/commands/apps/data/patch.d.ts +17 -0
- package/dist/commands/apps/data/patch.js +70 -0
- package/dist/commands/apps/data/put.js +1 -1
- package/dist/commands/apps/data/query.js +1 -1
- package/dist/commands/apps/installations/diff.d.ts +14 -0
- package/dist/commands/apps/installations/diff.js +45 -0
- package/dist/commands/apps/installations/events.d.ts +23 -0
- package/dist/commands/apps/installations/events.js +104 -0
- package/dist/commands/apps/installations/snapshot.d.ts +18 -0
- package/dist/commands/apps/installations/snapshot.js +60 -0
- package/dist/commands/apps/installations/versions.d.ts +12 -0
- package/dist/commands/apps/installations/versions.js +38 -0
- package/dist/commands/apps/logs.js +3 -0
- package/dist/commands/apps/preview.js +4 -2
- package/dist/commands/apps/pull.js +10 -1
- package/dist/commands/apps/push.js +36 -12
- package/dist/commands/apps/reference.d.ts +26 -0
- package/dist/commands/apps/reference.js +56 -0
- package/dist/commands/apps/rollback.d.ts +13 -0
- package/dist/commands/apps/rollback.js +47 -0
- package/dist/commands/apps/version/create.js +5 -0
- package/dist/commands/duties/accounting.js +6 -0
- package/dist/commands/duties/analytics/detail.js +6 -0
- package/dist/commands/duties/analytics/index.js +14 -0
- package/dist/commands/duties/analytics/replay.js +6 -0
- package/dist/commands/duties/cost.js +6 -0
- package/dist/commands/duties/delete.js +22 -19
- package/dist/commands/duties/doctor.d.ts +2 -1
- package/dist/commands/duties/doctor.js +17 -3
- package/dist/commands/duties/goals/link.js +4 -0
- package/dist/commands/duties/goals/unlink.js +4 -0
- package/dist/commands/duties/lineage.js +6 -1
- package/dist/commands/duties/links/list.js +6 -0
- package/dist/commands/duties/metrics.js +10 -0
- package/dist/commands/duties/observations.js +12 -0
- package/dist/commands/duties/operating-review.d.ts +4 -30
- package/dist/commands/duties/operating-review.js +28 -141
- package/dist/commands/duties/receipt-metrics.js +7 -0
- package/dist/commands/duties/receipt.js +7 -0
- package/dist/commands/duties/roster.js +14 -8
- package/dist/commands/duties/show.js +27 -9
- package/dist/commands/duties/status.js +18 -9
- package/dist/commands/duties/trigger-status.d.ts +2 -0
- package/dist/commands/duties/trigger-status.js +19 -1
- package/dist/commands/duties/wake-capabilities.d.ts +2 -0
- package/dist/commands/duties/wake-capabilities.js +32 -2
- package/dist/commands/followups/act.js +3 -0
- package/dist/commands/followups/remind.js +12 -3
- package/dist/commands/followups/show.js +6 -0
- package/dist/commands/harnesses/quota.js +1 -1
- package/dist/commands/spaces/notebook.d.ts +3 -7
- package/dist/commands/spaces/notebook.js +32 -8
- package/dist/commands/tasks/create.d.ts +2 -2
- package/dist/commands/tasks/create.js +3 -3
- package/dist/commands/tasks/list.d.ts +3 -41
- package/dist/commands/tasks/list.js +5 -53
- package/dist/generated/agent-guides.json +424 -101
- package/dist/generated/managed-instruction-guides.json +1 -1
- package/dist/lib/agent-activity.d.ts +153 -0
- package/dist/lib/agent-activity.js +241 -0
- package/dist/lib/always-on-runtime.d.ts +9 -0
- package/dist/lib/always-on-runtime.js +20 -0
- package/dist/lib/api-fetch.d.ts +10 -0
- package/dist/lib/api-fetch.js +12 -2
- package/dist/lib/appData.d.ts +28 -1
- package/dist/lib/appData.js +111 -9
- package/dist/lib/appInstallations.d.ts +9 -1
- package/dist/lib/appInstallations.js +100 -0
- package/dist/lib/apps-command.d.ts +1 -0
- package/dist/lib/apps-command.js +11 -0
- package/dist/lib/apps.d.ts +12 -0
- package/dist/lib/apps.js +28 -1
- package/dist/lib/appsAssets.d.ts +17 -0
- package/dist/lib/appsAssets.js +15 -0
- package/dist/lib/appsCheck.d.ts +1 -0
- package/dist/lib/appsCheck.js +1 -0
- package/dist/lib/appsFs.d.ts +18 -1
- package/dist/lib/appsFs.js +76 -19
- package/dist/lib/compasses.js +6 -0
- package/dist/lib/duties.d.ts +25 -2
- package/dist/lib/duties.js +58 -3
- package/dist/lib/duty-analytics.d.ts +2 -0
- package/dist/lib/duty-analytics.js +26 -0
- package/dist/lib/duty-goal-propagation.d.ts +2 -0
- package/dist/lib/duty-goal-propagation.js +18 -0
- package/dist/lib/duty-history-source.d.ts +4 -0
- package/dist/lib/duty-history-source.js +12 -0
- package/dist/lib/duty-ledgers.d.ts +4 -0
- package/dist/lib/duty-ledgers.js +4 -0
- package/dist/lib/duty-receipt-source.d.ts +4 -0
- package/dist/lib/duty-receipt-source.js +19 -0
- package/dist/lib/followups.d.ts +20 -0
- package/dist/lib/followups.js +10 -0
- package/dist/lib/held-messages.d.ts +22 -0
- package/dist/lib/held-messages.js +55 -0
- package/dist/lib/list-workspace.d.ts +40 -0
- package/dist/lib/list-workspace.js +58 -0
- package/dist/lib/miniComputer.d.ts +59 -0
- package/dist/lib/miniComputer.js +224 -0
- package/dist/lib/miniComputerCommand.d.ts +13 -0
- package/dist/lib/miniComputerCommand.js +48 -0
- package/dist/lib/roles.d.ts +3 -3
- package/dist/lib/space-notebook.js +15 -4
- package/dist/node_modules/@skrr-ai/data-provider/index.js +10465 -8383
- package/oclif.manifest.json +2849 -462
- package/package.json +14 -2
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWorkspaceContextRequired = isWorkspaceContextRequired;
|
|
4
|
+
exports.heldMessagesWorkspaceRefusal = heldMessagesWorkspaceRefusal;
|
|
3
5
|
exports.heldReasonLabel = heldReasonLabel;
|
|
4
6
|
exports.parseHeldOwnerMessages = parseHeldOwnerMessages;
|
|
5
7
|
exports.heldMessageLines = heldMessageLines;
|
|
8
|
+
const http_error_1 = require("./http-error");
|
|
6
9
|
/**
|
|
7
10
|
* Presentation of `GET /api/agents/:id/always-on/held-messages` for `skrr agents always-on
|
|
8
11
|
* held-messages`.
|
|
@@ -35,6 +38,58 @@ const HELD_REASON_LABELS = {
|
|
|
35
38
|
rate_limit: 'Held by an attention rate limit',
|
|
36
39
|
check_unavailable: 'A delivery check was unavailable',
|
|
37
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* What the server's `heldMessages` controller answers (HTTP 400) to a request that names no
|
|
43
|
+
* workspace. That route scopes the read to one workspace and, unlike `always-on status`, does not
|
|
44
|
+
* fall back to the agent's own, so a CLI session that never selected one gets this and nothing else.
|
|
45
|
+
* `skrr workspaces list` says an unselected session "resolves to your default workspace"; that holds
|
|
46
|
+
* for other routes, not this one.
|
|
47
|
+
*/
|
|
48
|
+
const WORKSPACE_REQUIRED_TEXT = 'Workspace context required';
|
|
49
|
+
/**
|
|
50
|
+
* Whether a thrown error is that refusal. The status alone is not enough: the same route also
|
|
51
|
+
* answers 400 `Invalid cursor`, which is a different problem with a different remedy.
|
|
52
|
+
*/
|
|
53
|
+
function isWorkspaceContextRequired(err) {
|
|
54
|
+
if ((0, http_error_1.httpStatusOf)(err) !== 400)
|
|
55
|
+
return false;
|
|
56
|
+
const record = typeof err === 'object' && err !== null ? err : {};
|
|
57
|
+
const body = record.body;
|
|
58
|
+
const bodyRecord = typeof body === 'object' && body !== null ? body : {};
|
|
59
|
+
return [record.message, bodyRecord.message, bodyRecord.error, body].some((text) => typeof text === 'string' && text.includes(WORKSPACE_REQUIRED_TEXT));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What to tell the caller when the server answered "Workspace context required". It depends on
|
|
63
|
+
* what the request actually carried, because the same refusal has two causes with different fixes:
|
|
64
|
+
*
|
|
65
|
+
* - NO workspace was sent (none selected, and the agent's own could not be read): pass one.
|
|
66
|
+
* - A workspace WAS sent, whether the caller's or the agent's own that the CLI defaulted to. The
|
|
67
|
+
* server sets `req.workspace` only for a workspace the caller belongs to and passes anything
|
|
68
|
+
* else through as null, so this means the caller is not a member of it (or it does not exist).
|
|
69
|
+
* Saying "none was selected" here would be false, and found live: an agent whose workspace the
|
|
70
|
+
* caller can see through a direct grant but does not belong to.
|
|
71
|
+
*
|
|
72
|
+
* `sentWorkspaceId` is the workspace the request carried (`withWorkspaceHeader`).
|
|
73
|
+
*/
|
|
74
|
+
function heldMessagesWorkspaceRefusal(sentWorkspaceId) {
|
|
75
|
+
const sent = sentWorkspaceId?.trim();
|
|
76
|
+
if (sent) {
|
|
77
|
+
return {
|
|
78
|
+
message: `The server did not accept workspace ${sent} for this read. Held messages are listed per ` +
|
|
79
|
+
'workspace you belong to, and this usually means you are not a member of it (or it does ' +
|
|
80
|
+
'not exist).',
|
|
81
|
+
suggestion: 'Pass --workspace <workspace-id> for a workspace of yours, or run `skrr workspaces use ' +
|
|
82
|
+
'<workspace-id>`. `skrr workspaces list` shows the ones you belong to.',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
message: 'The server scopes held messages to a workspace, and none was selected for this request. ' +
|
|
87
|
+
"The agent's own workspace could not be determined either.",
|
|
88
|
+
suggestion: 'Pass --workspace <workspace-id>, or run `skrr workspaces use <workspace-id>`. ' +
|
|
89
|
+
'`skrr workspaces list` shows yours, and `skrr agents always-on status <agent-id>` prints ' +
|
|
90
|
+
"the agent's workspace on its 'Agent workspace' line.",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
38
93
|
/** The sentence for a reason code, or an explicit "unrecognised" line carrying the code. */
|
|
39
94
|
function heldReasonLabel(reason) {
|
|
40
95
|
return HELD_REASON_LABELS[reason] ?? `Unrecognised reason: ${reason}`;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Which workspace a list reads, and why (OSK-21284). */
|
|
2
|
+
export type ListWorkspaceScope = {
|
|
3
|
+
source: 'all';
|
|
4
|
+
} | {
|
|
5
|
+
source: 'default';
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
workspaceName?: string;
|
|
8
|
+
workspaceCount: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A plain `tasks list` named no workspace, and the server answers that with a list across EVERY
|
|
12
|
+
* workspace the person belongs to. Its access filter has branches that belong to no single
|
|
13
|
+
* workspace, so no index can serve it in order: on production it timed out after about 6 s while
|
|
14
|
+
* the same list naming a workspace answered in about a second. `skrr workspaces list` already says
|
|
15
|
+
* an unselected session "resolves to your default workspace"; a list now reads it too.
|
|
16
|
+
*
|
|
17
|
+
* --all-workspaces the old, wider list, asked for by name (`workspaceScope=all`)
|
|
18
|
+
* a selected workspace, `--workspace`, or `skrr workspaces use` untouched: the choice stands
|
|
19
|
+
* an autonomous Agent session untouched: a workspace-less Agent session stays personal
|
|
20
|
+
* `--space`, `--calendar` untouched: a Space names its own scope
|
|
21
|
+
*
|
|
22
|
+
* Returns nothing when there is nothing to apply, and `source: 'default'` when the caller's
|
|
23
|
+
* default workspace should be used. `lookupDefault` is injected so the rule is tested without the
|
|
24
|
+
* network; a lookup that fails or finds no default changes nothing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveListWorkspace(flags: {
|
|
27
|
+
'all-workspaces'?: boolean;
|
|
28
|
+
space?: string;
|
|
29
|
+
calendar?: string;
|
|
30
|
+
}, env: NodeJS.ProcessEnv, lookupDefault: () => Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
count: number;
|
|
34
|
+
} | null>): Promise<ListWorkspaceScope | undefined>;
|
|
35
|
+
/** The default workspace the signed-in person's `skrr workspaces list` reports. */
|
|
36
|
+
export declare function lookupDefaultWorkspace(): Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
count: number;
|
|
40
|
+
} | null>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveListWorkspace = resolveListWorkspace;
|
|
4
|
+
exports.lookupDefaultWorkspace = lookupDefaultWorkspace;
|
|
5
|
+
const workspaces_1 = require("./workspaces");
|
|
6
|
+
/**
|
|
7
|
+
* A plain `tasks list` named no workspace, and the server answers that with a list across EVERY
|
|
8
|
+
* workspace the person belongs to. Its access filter has branches that belong to no single
|
|
9
|
+
* workspace, so no index can serve it in order: on production it timed out after about 6 s while
|
|
10
|
+
* the same list naming a workspace answered in about a second. `skrr workspaces list` already says
|
|
11
|
+
* an unselected session "resolves to your default workspace"; a list now reads it too.
|
|
12
|
+
*
|
|
13
|
+
* --all-workspaces the old, wider list, asked for by name (`workspaceScope=all`)
|
|
14
|
+
* a selected workspace, `--workspace`, or `skrr workspaces use` untouched: the choice stands
|
|
15
|
+
* an autonomous Agent session untouched: a workspace-less Agent session stays personal
|
|
16
|
+
* `--space`, `--calendar` untouched: a Space names its own scope
|
|
17
|
+
*
|
|
18
|
+
* Returns nothing when there is nothing to apply, and `source: 'default'` when the caller's
|
|
19
|
+
* default workspace should be used. `lookupDefault` is injected so the rule is tested without the
|
|
20
|
+
* network; a lookup that fails or finds no default changes nothing.
|
|
21
|
+
*/
|
|
22
|
+
async function resolveListWorkspace(flags, env, lookupDefault) {
|
|
23
|
+
if (flags['all-workspaces'])
|
|
24
|
+
return { source: 'all' };
|
|
25
|
+
if (env.OVERSKY_WORKSPACE_ID?.trim())
|
|
26
|
+
return undefined;
|
|
27
|
+
if (env.OVERSKY_AUTONOMOUS_SESSION === '1')
|
|
28
|
+
return undefined;
|
|
29
|
+
if (flags.space || flags.calendar)
|
|
30
|
+
return undefined;
|
|
31
|
+
let found = null;
|
|
32
|
+
try {
|
|
33
|
+
found = await lookupDefault();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
if (!found?.id)
|
|
39
|
+
return undefined;
|
|
40
|
+
return {
|
|
41
|
+
source: 'default',
|
|
42
|
+
workspaceId: found.id,
|
|
43
|
+
...(found.name ? { workspaceName: found.name } : {}),
|
|
44
|
+
workspaceCount: found.count,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** The default workspace the signed-in person's `skrr workspaces list` reports. */
|
|
48
|
+
async function lookupDefaultWorkspace() {
|
|
49
|
+
const listing = await (0, workspaces_1.listWorkspaceListing)();
|
|
50
|
+
if (!listing.defaultWorkspaceId)
|
|
51
|
+
return null;
|
|
52
|
+
const row = listing.rows.find((entry) => entry.id === listing.defaultWorkspaceId);
|
|
53
|
+
return {
|
|
54
|
+
id: listing.defaultWorkspaceId,
|
|
55
|
+
...(row?.name ? { name: row.name } : {}),
|
|
56
|
+
count: listing.rows.length,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type MiniComputerLayoutChangeResult, type MiniComputerLayoutOp } from '@skrr-ai/data-provider';
|
|
2
|
+
/**
|
|
3
|
+
* The CLI half of the Mini Computer records (Dynamic Agent Apps D3, D5): the words for what the server refused,
|
|
4
|
+
* the Tasks view a set of flags describes, and the lines a read prints. The records, their limits and their
|
|
5
|
+
* vocabularies are `@skrr-ai/data-provider` `miniComputer/`; nothing is declared again here.
|
|
6
|
+
*/
|
|
7
|
+
export interface MiniComputerRefusal {
|
|
8
|
+
status?: number;
|
|
9
|
+
code: string;
|
|
10
|
+
issue?: string;
|
|
11
|
+
message?: string;
|
|
12
|
+
currentRev?: number;
|
|
13
|
+
opCode?: string;
|
|
14
|
+
opIndex?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Read a refusal out of an API error, or null when the error is not one the Mini Computer routes made. */
|
|
17
|
+
export declare function readMiniComputerRefusal(error: unknown): MiniComputerRefusal | null;
|
|
18
|
+
export interface MiniComputerFailure {
|
|
19
|
+
message: string;
|
|
20
|
+
code: string;
|
|
21
|
+
exit: number;
|
|
22
|
+
retryable: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const MINI_COMPUTER_REFUSAL_CODES: string[];
|
|
25
|
+
export declare function describeMiniComputerRefusal(refusal: MiniComputerRefusal, bin?: string): MiniComputerFailure | null;
|
|
26
|
+
export interface TasksViewFlags {
|
|
27
|
+
name?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
'group-by'?: string;
|
|
30
|
+
sort?: string;
|
|
31
|
+
'sort-dir'?: string;
|
|
32
|
+
'quick-filter'?: string;
|
|
33
|
+
status?: string[];
|
|
34
|
+
priority?: string[];
|
|
35
|
+
label?: string[];
|
|
36
|
+
assignee?: string[];
|
|
37
|
+
search?: string;
|
|
38
|
+
'date-field'?: string;
|
|
39
|
+
'date-preset'?: string;
|
|
40
|
+
after?: string;
|
|
41
|
+
before?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The Tasks mini app configuration a set of flags describes (the server validates it again; this only shapes it).
|
|
45
|
+
* `type` is required: a view with no layout is not a view.
|
|
46
|
+
*/
|
|
47
|
+
export declare function tasksConfigFromFlags(flags: TasksViewFlags): {
|
|
48
|
+
view: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
export declare const TASKS_VIEW_DATE_FIELDS: readonly import("@skrr-ai/data-provider").DateFilterField[];
|
|
51
|
+
export declare const TASKS_VIEW_DATE_PRESETS: readonly import("@skrr-ai/data-provider").DateFilterPreset[];
|
|
52
|
+
/** One app's slot, in lines. */
|
|
53
|
+
export declare function formatMiniAppConfig(raw: unknown): string[];
|
|
54
|
+
/** The layout a person sees, in lines: the dock, the home grid, the folders, what is hidden, and what waits. */
|
|
55
|
+
export declare function formatMiniComputerLayout(raw: unknown): string[];
|
|
56
|
+
/** What a change answered, in lines for the Agent that asked. */
|
|
57
|
+
export declare function formatLayoutChangeResult(result: MiniComputerLayoutChangeResult): string[];
|
|
58
|
+
/** Operations from `--ops` or `--file` JSON text. Returns the raw array for the server to validate. */
|
|
59
|
+
export declare function parseOpsText(text: string): MiniComputerLayoutOp[];
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TASKS_VIEW_DATE_PRESETS = exports.TASKS_VIEW_DATE_FIELDS = exports.MINI_COMPUTER_REFUSAL_CODES = void 0;
|
|
4
|
+
exports.readMiniComputerRefusal = readMiniComputerRefusal;
|
|
5
|
+
exports.describeMiniComputerRefusal = describeMiniComputerRefusal;
|
|
6
|
+
exports.tasksConfigFromFlags = tasksConfigFromFlags;
|
|
7
|
+
exports.formatMiniAppConfig = formatMiniAppConfig;
|
|
8
|
+
exports.formatMiniComputerLayout = formatMiniComputerLayout;
|
|
9
|
+
exports.formatLayoutChangeResult = formatLayoutChangeResult;
|
|
10
|
+
exports.parseOpsText = parseOpsText;
|
|
11
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
12
|
+
/** Read a refusal out of an API error, or null when the error is not one the Mini Computer routes made. */
|
|
13
|
+
function readMiniComputerRefusal(error) {
|
|
14
|
+
const e = error;
|
|
15
|
+
if (!e || typeof e.body !== 'string')
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
const body = JSON.parse(e.body);
|
|
19
|
+
if (!body || typeof body !== 'object' || typeof body.code !== 'string')
|
|
20
|
+
return null;
|
|
21
|
+
return {
|
|
22
|
+
...(typeof e.status === 'number' ? { status: e.status } : {}),
|
|
23
|
+
code: body.code,
|
|
24
|
+
...(typeof body.issue === 'string' ? { issue: body.issue } : {}),
|
|
25
|
+
...(typeof body.message === 'string' ? { message: body.message } : {}),
|
|
26
|
+
...(typeof body.currentRev === 'number' ? { currentRev: body.currentRev } : {}),
|
|
27
|
+
...(typeof body.opCode === 'string' ? { opCode: body.opCode } : {}),
|
|
28
|
+
...(typeof body.opIndex === 'number' ? { opIndex: body.opIndex } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Every refusal the routes make, in words with the next step. A Record, so a new one has to be given words. */
|
|
36
|
+
const REFUSAL_WORDS = {
|
|
37
|
+
not_found: () => ({
|
|
38
|
+
message: 'There is no such Agent that you can see. Nothing was changed.',
|
|
39
|
+
code: 'MINI_COMPUTER_NOT_FOUND',
|
|
40
|
+
exit: 4,
|
|
41
|
+
retryable: false,
|
|
42
|
+
}),
|
|
43
|
+
forbidden: () => ({
|
|
44
|
+
message: 'You can see this Agent but may not edit it, so its app configuration cannot be changed.',
|
|
45
|
+
code: 'MINI_COMPUTER_FORBIDDEN',
|
|
46
|
+
exit: 3,
|
|
47
|
+
retryable: false,
|
|
48
|
+
}),
|
|
49
|
+
invalid_input: (r) => ({
|
|
50
|
+
message: `The server did not accept that${r.issue ? ` (${r.issue})` : ''}. Nothing was changed.`,
|
|
51
|
+
code: 'MINI_COMPUTER_INVALID',
|
|
52
|
+
exit: 2,
|
|
53
|
+
retryable: false,
|
|
54
|
+
}),
|
|
55
|
+
unknown_app: () => ({
|
|
56
|
+
message: 'That is not an app with a configuration slot. Run `skrr agents mini-computer show <agent-id>` for the apps, or use one of the built-in app ids (for example tasks).',
|
|
57
|
+
code: 'MINI_COMPUTER_UNKNOWN_APP',
|
|
58
|
+
exit: 2,
|
|
59
|
+
retryable: false,
|
|
60
|
+
}),
|
|
61
|
+
too_large: (r) => ({
|
|
62
|
+
message: `That configuration is too large${r.issue ? ` (${r.issue})` : ''}. Nothing was changed.`,
|
|
63
|
+
code: 'MINI_COMPUTER_TOO_LARGE',
|
|
64
|
+
exit: 2,
|
|
65
|
+
retryable: false,
|
|
66
|
+
}),
|
|
67
|
+
rev_mismatch: (r) => ({
|
|
68
|
+
message: `It is now at revision ${r.currentRev ?? '?'}: it changed since you read it. Nothing was written. Read it again and retry.`,
|
|
69
|
+
code: 'MINI_COMPUTER_REV_MISMATCH',
|
|
70
|
+
exit: 1,
|
|
71
|
+
retryable: false,
|
|
72
|
+
}),
|
|
73
|
+
busy: () => ({
|
|
74
|
+
message: 'Other changes kept landing at the same moment. Nothing was lost; run the command again.',
|
|
75
|
+
code: 'MINI_COMPUTER_BUSY',
|
|
76
|
+
exit: 1,
|
|
77
|
+
retryable: true,
|
|
78
|
+
}),
|
|
79
|
+
layout_unreadable: () => ({
|
|
80
|
+
message: 'The stored layout is not in a form this version understands. Nothing was changed.',
|
|
81
|
+
code: 'MINI_COMPUTER_LAYOUT_UNREADABLE',
|
|
82
|
+
exit: 1,
|
|
83
|
+
retryable: false,
|
|
84
|
+
}),
|
|
85
|
+
op_refused: (r) => ({
|
|
86
|
+
message: `${r.message ?? 'The change cannot be made.'}${r.opIndex !== undefined ? ` (operation ${r.opIndex + 1})` : ''} Nothing was changed.`,
|
|
87
|
+
code: `MINI_COMPUTER_${(r.opCode ?? 'OP_REFUSED').toUpperCase()}`,
|
|
88
|
+
exit: 1,
|
|
89
|
+
retryable: false,
|
|
90
|
+
}),
|
|
91
|
+
proposal_not_found: () => ({
|
|
92
|
+
message: 'That suggestion is no longer there.',
|
|
93
|
+
code: 'MINI_COMPUTER_PROPOSAL_NOT_FOUND',
|
|
94
|
+
exit: 4,
|
|
95
|
+
retryable: false,
|
|
96
|
+
}),
|
|
97
|
+
proposal_stale: (r) => ({
|
|
98
|
+
message: r.message ?? 'That suggestion no longer fits the layout.',
|
|
99
|
+
code: 'MINI_COMPUTER_PROPOSAL_STALE',
|
|
100
|
+
exit: 1,
|
|
101
|
+
retryable: false,
|
|
102
|
+
}),
|
|
103
|
+
change_not_found: () => ({
|
|
104
|
+
message: 'That change is not recorded.',
|
|
105
|
+
code: 'MINI_COMPUTER_CHANGE_NOT_FOUND',
|
|
106
|
+
exit: 4,
|
|
107
|
+
retryable: false,
|
|
108
|
+
}),
|
|
109
|
+
change_not_undoable: () => ({
|
|
110
|
+
message: 'That change can no longer be undone: the layout moved on after it.',
|
|
111
|
+
code: 'MINI_COMPUTER_CHANGE_NOT_UNDOABLE',
|
|
112
|
+
exit: 1,
|
|
113
|
+
retryable: false,
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
exports.MINI_COMPUTER_REFUSAL_CODES = Object.keys(REFUSAL_WORDS);
|
|
117
|
+
function describeMiniComputerRefusal(refusal, bin = 'skrr') {
|
|
118
|
+
const words = REFUSAL_WORDS[refusal.code];
|
|
119
|
+
return words ? words(refusal, bin) : null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The Tasks mini app configuration a set of flags describes (the server validates it again; this only shapes it).
|
|
123
|
+
* `type` is required: a view with no layout is not a view.
|
|
124
|
+
*/
|
|
125
|
+
function tasksConfigFromFlags(flags) {
|
|
126
|
+
const filters = {};
|
|
127
|
+
if (flags['quick-filter'])
|
|
128
|
+
filters.quickFilter = flags['quick-filter'];
|
|
129
|
+
if (flags.status?.length)
|
|
130
|
+
filters.statuses = flags.status;
|
|
131
|
+
if (flags.priority?.length)
|
|
132
|
+
filters.priorities = flags.priority;
|
|
133
|
+
if (flags.label?.length)
|
|
134
|
+
filters.labels = flags.label;
|
|
135
|
+
if (flags.assignee?.length)
|
|
136
|
+
filters.assignees = flags.assignee;
|
|
137
|
+
if (flags.search)
|
|
138
|
+
filters.search = flags.search;
|
|
139
|
+
const view = { viewType: flags.type };
|
|
140
|
+
if (flags.name)
|
|
141
|
+
view.name = flags.name;
|
|
142
|
+
if (flags['group-by'])
|
|
143
|
+
view.groupBy = flags['group-by'];
|
|
144
|
+
if (flags.sort || flags['sort-dir']) {
|
|
145
|
+
view.sort = { key: flags.sort ?? 'manual', dir: flags['sort-dir'] ?? 'asc' };
|
|
146
|
+
}
|
|
147
|
+
if (Object.keys(filters).length > 0)
|
|
148
|
+
view.filters = filters;
|
|
149
|
+
if (flags['date-preset'] || flags.after || flags.before) {
|
|
150
|
+
view.dateFilter = {
|
|
151
|
+
field: flags['date-field'] ?? 'dueOrScheduled',
|
|
152
|
+
...(flags['date-preset'] ? { preset: flags['date-preset'] } : {}),
|
|
153
|
+
...(flags.after ? { after: flags.after } : {}),
|
|
154
|
+
...(flags.before ? { before: flags.before } : {}),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return { view };
|
|
158
|
+
}
|
|
159
|
+
exports.TASKS_VIEW_DATE_FIELDS = data_provider_1.DATE_FILTER_FIELDS;
|
|
160
|
+
exports.TASKS_VIEW_DATE_PRESETS = data_provider_1.DATE_FILTER_PRESETS;
|
|
161
|
+
// ── reading it back ─────────────────────────────────────────────────────────
|
|
162
|
+
const labelOf = (id) => data_provider_1.MINI_COMPUTER_BUILTIN_APPS.find((app) => app.id === id)?.label ?? id;
|
|
163
|
+
/** One app's slot, in lines. */
|
|
164
|
+
function formatMiniAppConfig(raw) {
|
|
165
|
+
const entry = (0, data_provider_1.parseMiniAppConfigEntry)(raw);
|
|
166
|
+
if (entry === null)
|
|
167
|
+
return ['This configuration is not in a form this version of the CLI understands.'];
|
|
168
|
+
if (entry.config === null)
|
|
169
|
+
return [`${entry.appId}: default (nothing set)`];
|
|
170
|
+
const view = entry.config.view;
|
|
171
|
+
const lines = [
|
|
172
|
+
`${entry.appId}: revision ${entry.rev}${entry.via ? `, set by ${entry.via}` : ''}`,
|
|
173
|
+
];
|
|
174
|
+
if (view) {
|
|
175
|
+
lines.push(` view${view.name ? ` "${view.name}"` : ''}: ${view.viewType}${view.groupBy ? `, grouped by ${view.groupBy}` : ''}`);
|
|
176
|
+
}
|
|
177
|
+
lines.push(` ${JSON.stringify(entry.config)}`);
|
|
178
|
+
return lines;
|
|
179
|
+
}
|
|
180
|
+
/** The layout a person sees, in lines: the dock, the home grid, the folders, what is hidden, and what waits. */
|
|
181
|
+
function formatMiniComputerLayout(raw) {
|
|
182
|
+
const read = (0, data_provider_1.parseMiniComputerLayoutRead)(raw);
|
|
183
|
+
if (read === null) {
|
|
184
|
+
return [
|
|
185
|
+
'This layout is not in a form this version of the CLI understands, so it is not shown.',
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
const seen = (0, data_provider_1.describeMiniComputerLayout)(read.layout);
|
|
189
|
+
const names = (ids) => ids.map((id) => (id.startsWith('app:') ? id : labelOf(id)));
|
|
190
|
+
const lines = [
|
|
191
|
+
read.stored ? `Layout revision ${read.rev}.` : 'Layout: nothing arranged yet (the defaults).',
|
|
192
|
+
`Agent changes: ${read.agentChanges === 'apply' ? 'applied at once (undoable)' : 'proposed for the person to apply'} (the person chooses this).`,
|
|
193
|
+
`Dock (${seen.dock.length}/${data_provider_1.MINI_COMPUTER_MAX_DOCK_APPS}): ${names(seen.dock).join(', ') || '(empty)'}`,
|
|
194
|
+
`Home: ${names(seen.home.filter((id) => !id.startsWith('folder:'))).join(', ') || '(empty)'}`,
|
|
195
|
+
];
|
|
196
|
+
for (const folder of seen.folders) {
|
|
197
|
+
lines.push(`Folder "${folder.name}": ${names(folder.apps).join(', ') || '(empty)'}`);
|
|
198
|
+
}
|
|
199
|
+
if (seen.removed.length > 0)
|
|
200
|
+
lines.push(`Removed: ${names(seen.removed).join(', ')}`);
|
|
201
|
+
for (const proposal of read.proposals) {
|
|
202
|
+
lines.push(`Waiting for the person: ${proposal.summary.join('; ')}`);
|
|
203
|
+
}
|
|
204
|
+
const latest = read.changes[0];
|
|
205
|
+
if (latest)
|
|
206
|
+
lines.push(`Latest change: ${latest.summary.join('; ')}${latest.undoable ? ' (can be undone)' : ''}`);
|
|
207
|
+
return lines;
|
|
208
|
+
}
|
|
209
|
+
/** What a change answered, in lines for the Agent that asked. */
|
|
210
|
+
function formatLayoutChangeResult(result) {
|
|
211
|
+
const lines = result.summary.length > 0
|
|
212
|
+
? result.summary.map((line) => ` ${line}`)
|
|
213
|
+
: [' (no change: it already looks like that)'];
|
|
214
|
+
const heading = { applied: 'Applied', proposed: 'Proposed', noop: 'Unchanged' }[result.outcome];
|
|
215
|
+
return [`${heading}:`, ...lines, result.note];
|
|
216
|
+
}
|
|
217
|
+
/** Operations from `--ops` or `--file` JSON text. Returns the raw array for the server to validate. */
|
|
218
|
+
function parseOpsText(text) {
|
|
219
|
+
const parsed = JSON.parse(text);
|
|
220
|
+
const ops = Array.isArray(parsed) ? parsed : parsed?.ops;
|
|
221
|
+
if (!Array.isArray(ops))
|
|
222
|
+
throw new Error('expected a JSON array of operations, or { "ops": [...] }');
|
|
223
|
+
return ops;
|
|
224
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MiniComputerLayoutOp } from '@skrr-ai/data-provider';
|
|
2
|
+
import { BaseCommand } from '../base-command';
|
|
3
|
+
/**
|
|
4
|
+
* The base of every `skrr agents mini-computer` command. A refusal of the Mini Computer routes is an ANSWER with a
|
|
5
|
+
* next step (a stale revision, a dock that is full), so it comes under its own machine code and exit; one this does
|
|
6
|
+
* not know (not signed in, the server being down) is the base command's.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class MiniComputerCommand extends BaseCommand {
|
|
9
|
+
/** Say what went wrong. Never returns. */
|
|
10
|
+
protected failMiniComputer(error: unknown): never;
|
|
11
|
+
/** Send operations to the person's Mini Computer (their policy decides whether they apply) and print the answer. */
|
|
12
|
+
protected sendLayoutOps(agentId: string, ops: MiniComputerLayoutOp[], json: boolean): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MiniComputerCommand = void 0;
|
|
4
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
|
+
const base_command_1 = require("../base-command");
|
|
6
|
+
const miniComputer_1 = require("./miniComputer");
|
|
7
|
+
/**
|
|
8
|
+
* The base of every `skrr agents mini-computer` command. A refusal of the Mini Computer routes is an ANSWER with a
|
|
9
|
+
* next step (a stale revision, a dock that is full), so it comes under its own machine code and exit; one this does
|
|
10
|
+
* not know (not signed in, the server being down) is the base command's.
|
|
11
|
+
*/
|
|
12
|
+
class MiniComputerCommand extends base_command_1.BaseCommand {
|
|
13
|
+
/** Say what went wrong. Never returns. */
|
|
14
|
+
failMiniComputer(error) {
|
|
15
|
+
const refusal = (0, miniComputer_1.readMiniComputerRefusal)(error);
|
|
16
|
+
const failure = refusal ? (0, miniComputer_1.describeMiniComputerRefusal)(refusal, this.config.bin) : null;
|
|
17
|
+
if (refusal && failure) {
|
|
18
|
+
return this.failWithCliError({
|
|
19
|
+
message: failure.message,
|
|
20
|
+
code: failure.code,
|
|
21
|
+
...(refusal.status === undefined ? {} : { status: refusal.status }),
|
|
22
|
+
exit: failure.exit,
|
|
23
|
+
retryable: failure.retryable,
|
|
24
|
+
...(refusal.currentRev === undefined
|
|
25
|
+
? {}
|
|
26
|
+
: { details: { currentRev: refusal.currentRev } }),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return this.handleApiError(error);
|
|
30
|
+
}
|
|
31
|
+
/** Send operations to the person's Mini Computer (their policy decides whether they apply) and print the answer. */
|
|
32
|
+
async sendLayoutOps(agentId, ops, json) {
|
|
33
|
+
try {
|
|
34
|
+
const result = await data_provider_1.dataService.changeMiniComputerLayout(agentId, { ops });
|
|
35
|
+
if (json) {
|
|
36
|
+
this.log(this.agentJson(agentId, result));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const line of (0, miniComputer_1.formatLayoutChangeResult)(result))
|
|
40
|
+
this.log(line);
|
|
41
|
+
this.printAgentUrl(agentId);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.failMiniComputer(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MiniComputerCommand = MiniComputerCommand;
|
package/dist/lib/roles.d.ts
CHANGED
|
@@ -49,17 +49,17 @@ export declare const roleApi: {
|
|
|
49
49
|
successCriteria: {
|
|
50
50
|
id: string;
|
|
51
51
|
label: string;
|
|
52
|
-
evaluator?: "manual" | "
|
|
52
|
+
evaluator?: "manual" | "metric" | "source_state" | "task_state" | "goal_state" | "llm_review" | undefined;
|
|
53
53
|
config?: Record<string, unknown> | undefined;
|
|
54
54
|
}[];
|
|
55
55
|
sources: {
|
|
56
|
-
source: "space" | "tasks" | "memory" | "daemon" | "email" | "goal" | "files" | "local" | "browser" | "
|
|
56
|
+
source: "space" | "tasks" | "memory" | "daemon" | "email" | "goal" | "files" | "local" | "browser" | "metrics" | "monitor" | "github" | "conversations" | "agent_initiatives" | "messages" | "docs" | "documents" | "slack" | "calendar" | "product_metrics" | "business_metrics" | "state_monitor" | "agent_run";
|
|
57
57
|
enabled: boolean;
|
|
58
58
|
config?: Record<string, unknown> | undefined;
|
|
59
59
|
}[];
|
|
60
60
|
evidenceKeys: string[];
|
|
61
61
|
wake: {
|
|
62
|
-
mode: "manual" | "
|
|
62
|
+
mode: "manual" | "interval" | "daily" | "event_plus_interval";
|
|
63
63
|
timezone: string;
|
|
64
64
|
intervalMs?: number | undefined;
|
|
65
65
|
times?: string[] | undefined;
|
|
@@ -100,12 +100,19 @@ function detailLines(row) {
|
|
|
100
100
|
/** The lines `spaces notebook` prints for one page. */
|
|
101
101
|
function notebookLines(page, { webOrigin, binName }) {
|
|
102
102
|
const lines = [];
|
|
103
|
-
|
|
103
|
+
const unsupported = new Set(page.sources.filter((source) => source.state === 'unsupported').map((source) => source.kind));
|
|
104
|
+
// A server may include an older cached row for a now unsupported source.
|
|
105
|
+
// Do not display it as an authorized historical record.
|
|
106
|
+
const rows = page.rows.filter((row) => !unsupported.has(row.kind));
|
|
107
|
+
const allSourcesEnded = page.kinds.every((kind) => page.sources.find((source) => source.kind === kind)?.state === 'ended');
|
|
108
|
+
if (!rows.length) {
|
|
104
109
|
lines.push(page.nextCursor
|
|
105
110
|
? 'Nothing on this page.'
|
|
106
|
-
:
|
|
111
|
+
: allSourcesEnded
|
|
112
|
+
? `No available records in this listing (${page.kinds.map(data_provider_1.spaceNotebookKindLabel).join(', ')}).`
|
|
113
|
+
: 'No records from the available sources on this page; some sources were not read to their end.');
|
|
107
114
|
}
|
|
108
|
-
for (const row of
|
|
115
|
+
for (const row of rows) {
|
|
109
116
|
const tag = (KIND_TAG[row.kind] || row.kind).padEnd(10);
|
|
110
117
|
lines.push(`${row.at} ${tag} ${oneLine(row.title, 80)} · ${notebookAuthorLabel(row.author)}`);
|
|
111
118
|
if (row.summary) {
|
|
@@ -117,6 +124,10 @@ function notebookLines(page, { webOrigin, binName }) {
|
|
|
117
124
|
}
|
|
118
125
|
const notes = [];
|
|
119
126
|
for (const source of page.sources) {
|
|
127
|
+
if (source.state === 'unsupported') {
|
|
128
|
+
notes.push(`${(0, data_provider_1.spaceNotebookKindLabel)(source.kind)} are unavailable because their historical source cannot be verified.`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
120
131
|
if (source.state !== 'ended')
|
|
121
132
|
continue;
|
|
122
133
|
for (const window of source.windows || []) {
|
|
@@ -124,7 +135,7 @@ function notebookLines(page, { webOrigin, binName }) {
|
|
|
124
135
|
}
|
|
125
136
|
}
|
|
126
137
|
// Who may see a loop row, once per rule the page shows.
|
|
127
|
-
for (const row of
|
|
138
|
+
for (const row of rows) {
|
|
128
139
|
if ('visibility' in row && row.visibility) {
|
|
129
140
|
notes.push((0, data_provider_1.describeSpaceNotebookVisibility)(row.visibility));
|
|
130
141
|
}
|