@skrr-ai/cli 0.1.22 → 0.1.23
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/README.md +83 -73
- package/bin/dev-fallback.js +221 -0
- package/bin/run.js +43 -0
- package/dist/base-command.d.ts +15 -0
- package/dist/base-command.js +71 -10
- package/dist/commands/agents/attach-harness.d.ts +37 -0
- package/dist/commands/agents/attach-harness.js +102 -3
- package/dist/commands/agents/chat.d.ts +69 -1
- package/dist/commands/agents/chat.js +202 -22
- package/dist/commands/agents/create.d.ts +38 -0
- package/dist/commands/agents/create.js +95 -2
- package/dist/commands/agents/schedule-trace.js +11 -0
- package/dist/commands/agents/show.js +29 -1
- package/dist/commands/api-keys/create.d.ts +24 -0
- package/dist/commands/api-keys/create.js +80 -0
- package/dist/commands/api-keys/list.d.ts +11 -0
- package/dist/commands/api-keys/list.js +42 -0
- package/dist/commands/api-keys/revoke.d.ts +14 -0
- package/dist/commands/api-keys/revoke.js +33 -0
- package/dist/commands/api-keys/rotate.d.ts +19 -0
- package/dist/commands/api-keys/rotate.js +42 -0
- package/dist/commands/balance/index.d.ts +18 -0
- package/dist/commands/balance/index.js +29 -0
- package/dist/commands/balance/show.d.ts +25 -0
- package/dist/commands/balance/show.js +60 -0
- package/dist/commands/balance/statement.d.ts +19 -0
- package/dist/commands/balance/statement.js +52 -0
- package/dist/commands/browser/doctor.d.ts +11 -0
- package/dist/commands/browser/doctor.js +11 -0
- package/dist/commands/code/jobs/approve.d.ts +25 -0
- package/dist/commands/code/jobs/approve.js +52 -0
- package/dist/commands/code/jobs/cancel.d.ts +12 -0
- package/dist/commands/code/jobs/cancel.js +39 -0
- package/dist/commands/code/jobs/index.d.ts +19 -0
- package/dist/commands/code/jobs/index.js +38 -0
- package/dist/commands/code/jobs/list.d.ts +12 -0
- package/dist/commands/code/jobs/list.js +87 -0
- package/dist/commands/code/jobs/run.d.ts +32 -0
- package/dist/commands/code/jobs/run.js +151 -0
- package/dist/commands/code/jobs/show.d.ts +12 -0
- package/dist/commands/code/jobs/show.js +86 -0
- package/dist/commands/commitments/preflight.js +18 -4
- package/dist/commands/commitments/receipt-metrics.d.ts +39 -0
- package/dist/commands/commitments/receipt-metrics.js +78 -0
- package/dist/commands/convos/search.js +5 -5
- package/dist/commands/harnesses/leases/list.d.ts +3 -0
- package/dist/commands/harnesses/leases/list.js +59 -12
- package/dist/commands/harnesses/leases/show.js +36 -0
- package/dist/commands/harnesses/list.d.ts +18 -0
- package/dist/commands/harnesses/list.js +30 -0
- package/dist/commands/harnesses/products.js +48 -3
- package/dist/commands/harnesses/quota.d.ts +16 -0
- package/dist/commands/harnesses/quota.js +26 -1
- package/dist/commands/harnesses/usage.js +17 -0
- package/dist/commands/inbox/index.d.ts +2 -1
- package/dist/commands/inbox/index.js +27 -4
- package/dist/commands/login.js +4 -1
- package/dist/commands/machines/list.d.ts +1 -0
- package/dist/commands/machines/list.js +33 -5
- package/dist/commands/memory/approvals/issue.d.ts +18 -0
- package/dist/commands/memory/approvals/issue.js +63 -0
- package/dist/commands/memory/commit.js +5 -2
- package/dist/commands/memory/context.d.ts +3 -2
- package/dist/commands/memory/context.js +9 -11
- package/dist/commands/memory/delete.d.ts +1 -1
- package/dist/commands/memory/list.d.ts +1 -1
- package/dist/commands/memory/list.js +1 -1
- package/dist/commands/memory/mounts/resolve.d.ts +10 -0
- package/dist/commands/memory/mounts/resolve.js +27 -0
- package/dist/commands/memory/proposals/commit.d.ts +18 -0
- package/dist/commands/memory/proposals/commit.js +32 -0
- package/dist/commands/memory/proposals/create.d.ts +18 -0
- package/dist/commands/memory/proposals/create.js +56 -0
- package/dist/commands/memory/proposals/list.d.ts +13 -0
- package/dist/commands/memory/proposals/list.js +31 -0
- package/dist/commands/memory/proposals/promote.d.ts +22 -0
- package/dist/commands/memory/proposals/promote.js +33 -0
- package/dist/commands/memory/proposals/reject.d.ts +16 -0
- package/dist/commands/memory/proposals/reject.js +28 -0
- package/dist/commands/memory/rebuild-index.d.ts +20 -0
- package/dist/commands/memory/rebuild-index.js +25 -0
- package/dist/commands/memory/save.d.ts +1 -1
- package/dist/commands/memory/save.js +1 -1
- package/dist/commands/memory/search.d.ts +6 -3
- package/dist/commands/memory/search.js +27 -3
- package/dist/commands/memory/show.d.ts +1 -1
- package/dist/commands/memory/stores/archive.d.ts +14 -0
- package/dist/commands/memory/stores/archive.js +31 -0
- package/dist/commands/memory/stores/create.d.ts +12 -0
- package/dist/commands/memory/stores/create.js +30 -0
- package/dist/commands/memory/stores/delete.d.ts +15 -0
- package/dist/commands/memory/stores/delete.js +38 -0
- package/dist/commands/memory/stores/list.d.ts +10 -0
- package/dist/commands/memory/stores/list.js +29 -0
- package/dist/commands/memory/stores/show.d.ts +12 -0
- package/dist/commands/memory/stores/show.js +14 -0
- package/dist/commands/memory/stores/update.d.ts +15 -0
- package/dist/commands/memory/stores/update.js +39 -0
- package/dist/commands/memory/sync/delete.d.ts +13 -0
- package/dist/commands/memory/sync/delete.js +35 -0
- package/dist/commands/memory/sync/pull.d.ts +19 -0
- package/dist/commands/memory/sync/pull.js +52 -0
- package/dist/commands/memory/sync/push.d.ts +18 -0
- package/dist/commands/memory/sync/push.js +115 -0
- package/dist/commands/memory/sync/resolve.d.ts +23 -0
- package/dist/commands/memory/sync/resolve.js +27 -0
- package/dist/commands/memory/sync/status.d.ts +9 -0
- package/dist/commands/memory/sync/status.js +22 -0
- package/dist/commands/memory/topics/archive.d.ts +20 -0
- package/dist/commands/memory/topics/archive.js +29 -0
- package/dist/commands/memory/topics/create.d.ts +23 -0
- package/dist/commands/memory/topics/create.js +46 -0
- package/dist/commands/memory/topics/delete.d.ts +22 -0
- package/dist/commands/memory/topics/delete.js +30 -0
- package/dist/commands/memory/topics/forget.d.ts +22 -0
- package/dist/commands/memory/topics/forget.js +29 -0
- package/dist/commands/memory/topics/list.d.ts +13 -0
- package/dist/commands/memory/topics/list.js +22 -0
- package/dist/commands/memory/topics/move.d.ts +22 -0
- package/dist/commands/memory/topics/move.js +26 -0
- package/dist/commands/memory/topics/show.d.ts +17 -0
- package/dist/commands/memory/topics/show.js +21 -0
- package/dist/commands/memory/topics/update.d.ts +23 -0
- package/dist/commands/memory/topics/update.js +27 -0
- package/dist/commands/memory/tree.d.ts +5 -2
- package/dist/commands/memory/tree.js +20 -2
- package/dist/commands/memory/update.d.ts +1 -1
- package/dist/commands/memory/versions/list.d.ts +16 -0
- package/dist/commands/memory/versions/list.js +22 -0
- package/dist/commands/memory/versions/redact.d.ts +21 -0
- package/dist/commands/memory/versions/redact.js +22 -0
- package/dist/commands/memory/versions/restore.d.ts +20 -0
- package/dist/commands/memory/versions/restore.js +16 -0
- package/dist/commands/memory/versions/show.d.ts +15 -0
- package/dist/commands/memory/versions/show.js +17 -0
- package/dist/commands/messages/list.js +25 -8
- package/dist/commands/messages/show.js +10 -0
- package/dist/commands/store/install.js +5 -1
- package/dist/commands/store/releases.js +1 -1
- package/dist/commands/store/update.js +5 -1
- package/dist/commands/subscriptions/cancel.js +5 -1
- package/dist/commands/subscriptions/health.js +5 -1
- package/dist/commands/subscriptions/status.js +5 -1
- package/dist/commands/subscriptions/subscribe.js +5 -1
- package/dist/commands/tasks/activity.d.ts +2 -3
- package/dist/commands/tasks/activity.js +15 -5
- package/dist/commands/tasks/complete.d.ts +18 -150
- package/dist/commands/tasks/complete.js +161 -600
- package/dist/commands/tasks/create.d.ts +5 -0
- package/dist/commands/tasks/create.js +107 -4
- package/dist/commands/tasks/deliverable/add.d.ts +8 -0
- package/dist/commands/tasks/deliverable/add.js +41 -8
- package/dist/commands/tasks/deliverable/confirm.d.ts +5 -5
- package/dist/commands/tasks/deliverable/confirm.js +9 -18
- package/dist/commands/tasks/deliverable/list.d.ts +12 -0
- package/dist/commands/tasks/deliverable/list.js +37 -0
- package/dist/commands/tasks/events/append.d.ts +2 -0
- package/dist/commands/tasks/events/append.js +11 -4
- package/dist/commands/tasks/events/list.d.ts +1 -0
- package/dist/commands/tasks/events/list.js +1 -0
- package/dist/commands/tasks/events/tail.d.ts +1 -0
- package/dist/commands/tasks/events/tail.js +1 -0
- package/dist/commands/tasks/expectations/assess.d.ts +21 -0
- package/dist/commands/tasks/expectations/assess.js +77 -0
- package/dist/commands/tasks/expectations.js +14 -18
- package/dist/commands/tasks/judge.d.ts +1 -0
- package/dist/commands/tasks/judge.js +2 -1
- package/dist/commands/tasks/output.d.ts +2 -11
- package/dist/commands/tasks/output.js +64 -145
- package/dist/commands/tasks/report.d.ts +3 -3
- package/dist/commands/tasks/report.js +64 -41
- package/dist/commands/tasks/resource/add.d.ts +23 -0
- package/dist/commands/tasks/resource/add.js +76 -0
- package/dist/commands/tasks/resource/list.d.ts +13 -0
- package/dist/commands/tasks/resource/list.js +41 -0
- package/dist/commands/tasks/result/show.d.ts +13 -0
- package/dist/commands/tasks/result/show.js +46 -0
- package/dist/commands/tasks/result/submit.d.ts +26 -0
- package/dist/commands/tasks/result/submit.js +134 -0
- package/dist/commands/tasks/resume/save.d.ts +16 -0
- package/dist/commands/tasks/resume/save.js +59 -0
- package/dist/commands/tasks/resume/show.d.ts +13 -0
- package/dist/commands/tasks/resume/show.js +35 -0
- package/dist/commands/tasks/review.d.ts +17 -0
- package/dist/commands/tasks/review.js +54 -0
- package/dist/commands/tasks/runs.js +5 -0
- package/dist/commands/tasks/timeline.d.ts +2 -2
- package/dist/commands/tasks/timeline.js +10 -23
- package/dist/commands/tasks/updates/add.d.ts +22 -0
- package/dist/commands/tasks/updates/add.js +101 -0
- package/dist/commands/tasks/updates/list.d.ts +15 -0
- package/dist/commands/tasks/updates/list.js +57 -0
- package/dist/commands/tasks/waive.d.ts +1 -0
- package/dist/commands/tasks/waive.js +2 -1
- package/dist/lib/agentic-stream.d.ts +257 -0
- package/dist/lib/agentic-stream.js +490 -33
- package/dist/lib/balance.d.ts +8 -0
- package/dist/lib/commitment-product.d.ts +10 -1
- package/dist/lib/commitment-product.js +66 -2
- package/dist/lib/commitments.d.ts +2 -1
- package/dist/lib/commitments.js +1 -0
- package/dist/lib/conversation-search.d.ts +3 -0
- package/dist/lib/conversation-search.js +75 -0
- package/dist/lib/execution-target.d.ts +21 -0
- package/dist/lib/execution-target.js +22 -6
- package/dist/lib/harnesses.d.ts +82 -6
- package/dist/lib/harnesses.js +30 -2
- package/dist/lib/hosted-machines.js +9 -0
- package/dist/lib/inbox.d.ts +2 -1
- package/dist/lib/machines.d.ts +17 -0
- package/dist/lib/machines.js +29 -0
- package/dist/lib/managed-agent-keys.d.ts +104 -0
- package/dist/lib/managed-agent-keys.js +50 -0
- package/dist/lib/memory-scope.d.ts +4 -3
- package/dist/lib/memory-scope.js +9 -9
- package/dist/lib/memory-sync.d.ts +114 -0
- package/dist/lib/memory-sync.js +730 -0
- package/dist/lib/message-provenance.d.ts +42 -0
- package/dist/lib/message-provenance.js +89 -0
- package/dist/lib/scoped-memory-command.d.ts +68 -0
- package/dist/lib/scoped-memory-command.js +183 -0
- package/dist/lib/session-task-endpoints.d.ts +1 -1
- package/dist/lib/session-task-endpoints.js +7 -0
- package/dist/lib/sky-code-broker.d.ts +47 -0
- package/dist/lib/sky-code-broker.js +50 -0
- package/dist/lib/sky-code-doctor.js +10 -1
- package/dist/lib/task-artifact-flags.d.ts +2 -0
- package/dist/lib/task-artifact-flags.js +7 -0
- package/dist/lib/task-execution.d.ts +4 -5
- package/dist/lib/task-execution.js +4 -5
- package/dist/lib/task-extras.d.ts +1 -5
- package/dist/lib/task-extras.js +1 -5
- package/dist/lib/task-transcript.d.ts +5 -7
- package/dist/lib/task-transcript.js +8 -16
- package/dist/lib/tasks.d.ts +7 -21
- package/dist/lib/tasks.js +17 -20
- package/dist/lib/triggers.d.ts +39 -1
- package/dist/lib/triggers.js +70 -2
- package/dist/lib/usage-discovery.d.ts +17 -1
- package/dist/lib/usage-discovery.js +17 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +3733 -3618
- package/oclif.manifest.json +16201 -10377
- package/package.json +26 -5
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
|
-
const
|
|
5
|
+
const scoped_memory_command_1 = require("../../lib/scoped-memory-command");
|
|
6
6
|
const format_1 = require("../../lib/format");
|
|
7
7
|
const memory_scope_1 = require("../../lib/memory-scope");
|
|
8
|
-
class MemorySearch extends
|
|
8
|
+
class MemorySearch extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
9
9
|
static description = 'Semantic (hybrid vector + text) search over a memory pool — the same ranking the agent sees';
|
|
10
10
|
static examples = [
|
|
11
11
|
'<%= config.bin %> memory search "dark mode preference"',
|
|
12
12
|
'<%= config.bin %> memory search "billing" --agent agent_abc123',
|
|
13
|
-
'<%= config.bin %> memory search "team norms" --tier workspace --workspace ws_123',
|
|
13
|
+
'<%= config.bin %> memory search "team norms" --tier workspace --pool-workspace ws_123',
|
|
14
14
|
'<%= config.bin %> memory search "onboarding" --max-results 10 --json',
|
|
15
15
|
];
|
|
16
16
|
static args = {
|
|
@@ -21,10 +21,34 @@ class MemorySearch extends base_command_1.BaseCommand {
|
|
|
21
21
|
'max-results': core_1.Flags.integer({ description: 'Maximum results (1-50)', default: 6 }),
|
|
22
22
|
'min-score': core_1.Flags.string({ description: 'Minimum score 0-1 (default: 0.35)' }),
|
|
23
23
|
...memory_scope_1.memoryScopeFlags,
|
|
24
|
+
store: core_1.Flags.string({ description: 'Canonical Memory Store ID' }),
|
|
25
|
+
scope: core_1.Flags.string({ description: 'Canonical owner scope: agent:<id> or space:<id>' }),
|
|
26
|
+
'space-context': core_1.Flags.string({ description: 'Current Space context for canonical mounts' }),
|
|
24
27
|
};
|
|
25
28
|
async run() {
|
|
26
29
|
this.requireAuth();
|
|
27
30
|
const { args, flags } = await this.parse(MemorySearch);
|
|
31
|
+
if (flags.store || flags.scope) {
|
|
32
|
+
if (!flags.agent)
|
|
33
|
+
this.error('--agent is required with --store or --scope.', { exit: 2 });
|
|
34
|
+
const canonicalFlags = {
|
|
35
|
+
agent: flags.agent,
|
|
36
|
+
store: flags.store,
|
|
37
|
+
scope: flags.scope,
|
|
38
|
+
space: flags['space-context'],
|
|
39
|
+
json: flags.json,
|
|
40
|
+
};
|
|
41
|
+
const store = await this.resolveStore(canonicalFlags);
|
|
42
|
+
const response = await this.memoryApi(flags.agent, `/stores/${store.id}/search${this.query(canonicalFlags, { q: args.query, limit: flags['max-results'] })}`);
|
|
43
|
+
if (flags.json)
|
|
44
|
+
this.log(JSON.stringify(response, null, 2));
|
|
45
|
+
else if (!response.results?.length)
|
|
46
|
+
this.log(`No memories matched "${args.query}".`);
|
|
47
|
+
else
|
|
48
|
+
for (const result of response.results)
|
|
49
|
+
this.log(`${Number(result.score || 0).toFixed(2)} ${result.node.path} ${result.content}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
28
52
|
const scope = (0, memory_scope_1.resolveMemoryScopeOrFail)(flags, (m) => this.error(m, { exit: 1 }));
|
|
29
53
|
let minScore;
|
|
30
54
|
if (flags['min-score'] !== undefined) {
|
|
@@ -8,7 +8,7 @@ export default class MemoryShow extends BaseCommand {
|
|
|
8
8
|
static flags: {
|
|
9
9
|
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
10
|
tier: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
-
workspace: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
'pool-workspace': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
12
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
13
|
};
|
|
14
14
|
run(): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemoryStoresArchive extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'expected-revision': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
5
|
+
class MemoryStoresArchive extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
6
|
+
static description = 'Archive a Memory Store before deletion';
|
|
7
|
+
static flags = {
|
|
8
|
+
...scoped_memory_command_1.scopedMemoryFlags,
|
|
9
|
+
'expected-revision': core_1.Flags.integer({ required: true }),
|
|
10
|
+
'dry-run': core_1.Flags.boolean({
|
|
11
|
+
description: 'Run server validation without archiving the Store',
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
this.requireAuth();
|
|
16
|
+
const { flags } = await this.parse(MemoryStoresArchive);
|
|
17
|
+
const store = await this.resolveStore(flags, { write: true });
|
|
18
|
+
const body = {
|
|
19
|
+
status: 'archived',
|
|
20
|
+
expectedRevision: flags['expected-revision'],
|
|
21
|
+
...(flags.space ? { spaceId: flags.space } : {}),
|
|
22
|
+
...(flags['dry-run'] ? { dryRun: true } : {}),
|
|
23
|
+
};
|
|
24
|
+
const result = await this.memoryApi(flags.agent, `/stores/${encodeURIComponent(store.id)}`, {
|
|
25
|
+
method: 'PATCH',
|
|
26
|
+
body,
|
|
27
|
+
});
|
|
28
|
+
this.print(result, flags.json, flags['dry-run'] ? 'Dry run: no Store changed.' : `Archived Memory Store ${store.id}.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = MemoryStoresArchive;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemoryStoresCreate extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
5
|
+
class MemoryStoresCreate extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
6
|
+
static description = 'Ensure the authorized Agent or current Space Memory Store exists';
|
|
7
|
+
static flags = {
|
|
8
|
+
agent: core_1.Flags.string({ required: true }),
|
|
9
|
+
space: core_1.Flags.string(),
|
|
10
|
+
scope: core_1.Flags.string({ required: true, description: 'agent:<id> or space:<id>' }),
|
|
11
|
+
json: core_1.Flags.boolean(),
|
|
12
|
+
'dry-run': core_1.Flags.boolean({
|
|
13
|
+
description: 'Run server validation without creating the Store',
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
this.requireAuth();
|
|
18
|
+
const { flags } = await this.parse(MemoryStoresCreate);
|
|
19
|
+
const body = {
|
|
20
|
+
scope: flags.scope,
|
|
21
|
+
...(flags.space ? { spaceId: flags.space } : {}),
|
|
22
|
+
...(flags['dry-run'] ? { dryRun: true } : {}),
|
|
23
|
+
};
|
|
24
|
+
const result = await this.memoryApi(flags.agent, '/stores', { method: 'POST', body });
|
|
25
|
+
this.print(result, flags.json, flags['dry-run']
|
|
26
|
+
? 'Dry run: Store ensure request passed server validation.'
|
|
27
|
+
: `Memory Store ${result.id} is ready.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = MemoryStoresCreate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemoryStoresDelete extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'expected-revision': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
yes: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const prompt_1 = require("../../../lib/prompt");
|
|
5
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
6
|
+
class MemoryStoresDelete extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
7
|
+
static description = 'Permanently delete an already-archived Memory Store';
|
|
8
|
+
static flags = {
|
|
9
|
+
...scoped_memory_command_1.scopedMemoryFlags,
|
|
10
|
+
'expected-revision': core_1.Flags.integer({ required: true }),
|
|
11
|
+
yes: core_1.Flags.boolean({ char: 'y' }),
|
|
12
|
+
'dry-run': core_1.Flags.boolean({
|
|
13
|
+
description: 'Run server validation without deleting the Store',
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
this.requireAuth();
|
|
18
|
+
const { flags } = await this.parse(MemoryStoresDelete);
|
|
19
|
+
const store = await this.resolveStore(flags, { write: true });
|
|
20
|
+
if (!flags['dry-run']) {
|
|
21
|
+
const ok = await (0, prompt_1.confirmDestructive)(`Permanently delete archived Memory Store ${store.id}?`, flags.yes).catch((error) => this.error(error.message, { exit: error.exit || 7 }));
|
|
22
|
+
if (!ok)
|
|
23
|
+
return this.log('Cancelled.');
|
|
24
|
+
}
|
|
25
|
+
const body = {
|
|
26
|
+
confirmStoreId: store.id,
|
|
27
|
+
expectedRevision: flags['expected-revision'],
|
|
28
|
+
...(flags.space ? { spaceId: flags.space } : {}),
|
|
29
|
+
...(flags['dry-run'] ? { dryRun: true } : {}),
|
|
30
|
+
};
|
|
31
|
+
const result = await this.memoryApi(flags.agent, `/stores/${encodeURIComponent(store.id)}`, {
|
|
32
|
+
method: 'DELETE',
|
|
33
|
+
body,
|
|
34
|
+
});
|
|
35
|
+
this.print(result, flags.json, flags['dry-run'] ? 'Dry run: no Store deleted.' : `Deleted Memory Store ${store.id}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = MemoryStoresDelete;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemoryStoresList extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const data_schemas_1 = require("@skrr-ai/data-schemas");
|
|
5
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
6
|
+
class MemoryStoresList extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
7
|
+
static description = 'List Memory Stores mounted for an Agent session';
|
|
8
|
+
static flags = {
|
|
9
|
+
agent: core_1.Flags.string({ required: true }),
|
|
10
|
+
space: core_1.Flags.string({ description: 'Current Space context' }),
|
|
11
|
+
json: core_1.Flags.boolean({ description: 'Output stable JSON' }),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
this.requireAuth();
|
|
15
|
+
const { flags } = await this.parse(MemoryStoresList);
|
|
16
|
+
const response = await this.memoryApi(flags.agent, `/stores${this.query(flags)}`);
|
|
17
|
+
const result = {
|
|
18
|
+
stores: response.stores.map((store) => data_schemas_1.MountedMemoryStoreSchema.parse(store)),
|
|
19
|
+
};
|
|
20
|
+
if (flags.json)
|
|
21
|
+
return this.log(JSON.stringify(result, null, 2));
|
|
22
|
+
for (const store of result.stores) {
|
|
23
|
+
this.log(`${store.id} ${store.owner.kind}:${store.owner.id} ${store.mount.access} r${store.revision}`);
|
|
24
|
+
}
|
|
25
|
+
if (!result.stores.length)
|
|
26
|
+
this.log('No mounted Memory Stores.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = MemoryStoresList;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemoryStoresShow extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
4
|
+
class MemoryStoresShow extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
5
|
+
static description = 'Show one mounted Memory Store';
|
|
6
|
+
static flags = scoped_memory_command_1.scopedMemoryFlags;
|
|
7
|
+
async run() {
|
|
8
|
+
this.requireAuth();
|
|
9
|
+
const { flags } = await this.parse(MemoryStoresShow);
|
|
10
|
+
const store = await this.resolveStore(flags);
|
|
11
|
+
this.print(store, flags.json, `${store.id} ${store.owner.kind}:${store.owner.id} ${store.status} r${store.revision}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = MemoryStoresShow;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemoryStoresUpdate extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
attributes: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
'expected-revision': import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
5
|
+
class MemoryStoresUpdate extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
6
|
+
static description = 'Update Memory Store metadata with revision CAS';
|
|
7
|
+
static flags = {
|
|
8
|
+
...scoped_memory_command_1.scopedMemoryFlags,
|
|
9
|
+
attributes: core_1.Flags.string({ description: 'Complete attributes JSON object', required: true }),
|
|
10
|
+
'expected-revision': core_1.Flags.integer({ required: true }),
|
|
11
|
+
'dry-run': core_1.Flags.boolean({
|
|
12
|
+
description: 'Run server validation without updating the Store',
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
this.requireAuth();
|
|
17
|
+
const { flags } = await this.parse(MemoryStoresUpdate);
|
|
18
|
+
const store = await this.resolveStore(flags, { write: true });
|
|
19
|
+
let attributes;
|
|
20
|
+
try {
|
|
21
|
+
attributes = JSON.parse(flags.attributes);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
this.error('--attributes must be valid JSON.', { exit: 2 });
|
|
25
|
+
}
|
|
26
|
+
const body = {
|
|
27
|
+
attributes,
|
|
28
|
+
expectedRevision: flags['expected-revision'],
|
|
29
|
+
...(flags.space ? { spaceId: flags.space } : {}),
|
|
30
|
+
...(flags['dry-run'] ? { dryRun: true } : {}),
|
|
31
|
+
};
|
|
32
|
+
const result = await this.memoryApi(flags.agent, `/stores/${encodeURIComponent(store.id)}`, {
|
|
33
|
+
method: 'PATCH',
|
|
34
|
+
body,
|
|
35
|
+
});
|
|
36
|
+
this.print(result, flags.json, flags['dry-run'] ? 'Dry run: no Store changed.' : `Updated Memory Store ${store.id}.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = MemoryStoresUpdate;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class MemorySyncDelete extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
memoryId: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
yes: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../../base-command");
|
|
5
|
+
const memory_sync_1 = require("../../../lib/memory-sync");
|
|
6
|
+
const prompt_1 = require("../../../lib/prompt");
|
|
7
|
+
class MemorySyncDelete extends base_command_1.BaseCommand {
|
|
8
|
+
static description = 'Delete a local topic file and stage its version-bound tombstone for the next sync push';
|
|
9
|
+
static args = {
|
|
10
|
+
memoryId: core_1.Args.string({
|
|
11
|
+
description: 'Materialized Memory topic ID',
|
|
12
|
+
required: true,
|
|
13
|
+
ignoreStdin: true,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
static flags = {
|
|
17
|
+
dir: core_1.Flags.string({ description: 'Materialized Memory directory', required: true }),
|
|
18
|
+
yes: core_1.Flags.boolean({ char: 'y', description: 'Confirm local deletion without prompting' }),
|
|
19
|
+
json: core_1.Flags.boolean({ description: 'Output stable JSON' }),
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { args, flags } = await this.parse(MemorySyncDelete);
|
|
23
|
+
const ok = await (0, prompt_1.confirmDestructive)(`Delete the local file for Memory topic ${args.memoryId} and stage its permanent deletion?`, flags.yes).catch((error) => this.error(error.message, { exit: error.exit || 7 }));
|
|
24
|
+
if (!ok)
|
|
25
|
+
return this.log('Cancelled.');
|
|
26
|
+
const result = await (0, memory_sync_1.stageLocalDelete)(flags.dir, args.memoryId);
|
|
27
|
+
if (flags.json)
|
|
28
|
+
this.log(JSON.stringify(result, null, 2));
|
|
29
|
+
else {
|
|
30
|
+
this.log(`Staged deletion of ${result.file}.`);
|
|
31
|
+
this.log('Run `skrr memory sync push` with the same Store context to commit it.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = MemorySyncDelete;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemorySyncPull extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
cursor: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
'authorization-generation': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
'expected-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
'idempotency-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
'privacy-approval': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
5
|
+
const memory_sync_1 = require("../../../lib/memory-sync");
|
|
6
|
+
class MemorySyncPull extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
7
|
+
static description = 'Pull canonical Store changes into a local materialized mount';
|
|
8
|
+
static flags = {
|
|
9
|
+
...scoped_memory_command_1.mutationFlags,
|
|
10
|
+
dir: core_1.Flags.string({ required: true }),
|
|
11
|
+
cursor: core_1.Flags.string(),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
this.requireAuth();
|
|
15
|
+
const { flags } = await this.parse(MemorySyncPull);
|
|
16
|
+
const binding = await (0, memory_sync_1.readMaterializationBinding)(flags.dir);
|
|
17
|
+
(0, memory_sync_1.assertMaterializationSpaceContext)(binding.manifest, flags.space);
|
|
18
|
+
const mounted = await this.memoryApi(flags.agent, `/mounts${this.query(flags)}`);
|
|
19
|
+
if (binding.manifest &&
|
|
20
|
+
!mounted.mounts.some((mount) => mount.storeId === binding.manifest?.storeId)) {
|
|
21
|
+
const revoked = await (0, memory_sync_1.revokeMaterialization)(flags.dir, Math.max(1, ...mounted.mounts.map((mount) => mount.authorizationGeneration + 1)));
|
|
22
|
+
const result = { status: 'revoked', storeId: binding.manifest.storeId, ...revoked };
|
|
23
|
+
return this.print(result, flags.json, `Access revoked; removed ${revoked.removed} protected projection(s).`);
|
|
24
|
+
}
|
|
25
|
+
const store = await this.resolveStore(flags);
|
|
26
|
+
const cursor = flags.cursor || (binding.manifest?.storeId === store.id ? binding.cursor : null);
|
|
27
|
+
if (cursor && !flags['dry-run']) {
|
|
28
|
+
let after = cursor;
|
|
29
|
+
let changed = 0;
|
|
30
|
+
let conflicts = 0;
|
|
31
|
+
let hasMore = true;
|
|
32
|
+
while (hasMore) {
|
|
33
|
+
const delta = await this.memoryApi(flags.agent, `/stores/${store.id}/sync/changes${this.query(flags, { after, limit: 500 })}`);
|
|
34
|
+
if (delta.resetRequired) {
|
|
35
|
+
const snapshot = await this.memoryApi(flags.agent, `/stores/${store.id}/sync/snapshot${this.query(flags)}`);
|
|
36
|
+
const reset = await (0, memory_sync_1.pullSnapshot)(flags.dir, snapshot);
|
|
37
|
+
return this.print({ ...reset, reset: true, reason: delta.reason }, flags.json, `Cursor expired; refreshed the full snapshot (${reset.changed} change(s)).`);
|
|
38
|
+
}
|
|
39
|
+
const applied = await (0, memory_sync_1.pullChanges)(flags.dir, delta);
|
|
40
|
+
changed += applied.changed;
|
|
41
|
+
conflicts += applied.conflicts;
|
|
42
|
+
after = applied.cursor;
|
|
43
|
+
hasMore = delta.hasMore === true;
|
|
44
|
+
}
|
|
45
|
+
return this.print({ changed, conflicts, cursor: after, incremental: true }, flags.json, `Pulled ${changed} incremental change(s).`);
|
|
46
|
+
}
|
|
47
|
+
const snapshot = await this.memoryApi(flags.agent, `/stores/${store.id}/sync/snapshot${this.query(flags)}`);
|
|
48
|
+
const result = await (0, memory_sync_1.pullSnapshot)(flags.dir, snapshot, { dryRun: flags['dry-run'] });
|
|
49
|
+
this.print(result, flags.json, `${flags['dry-run'] ? 'Would pull' : 'Pulled'} ${result.changed ?? 0} change(s).`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = MemorySyncPull;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemorySyncPush extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
6
|
+
'authorization-generation': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
'expected-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
'idempotency-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
'privacy-approval': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const scoped_memory_command_1 = require("../../../lib/scoped-memory-command");
|
|
5
|
+
const api_fetch_1 = require("../../../lib/api-fetch");
|
|
6
|
+
const memory_sync_1 = require("../../../lib/memory-sync");
|
|
7
|
+
class MemorySyncPush extends scoped_memory_command_1.ScopedMemoryCommand {
|
|
8
|
+
static description = 'Push eligible local topic edits through canonical versioned mutations';
|
|
9
|
+
static flags = { ...scoped_memory_command_1.mutationFlags, dir: core_1.Flags.string({ required: true }) };
|
|
10
|
+
async run() {
|
|
11
|
+
this.requireAuth();
|
|
12
|
+
const { flags } = await this.parse(MemorySyncPush);
|
|
13
|
+
const store = await this.resolveStore(flags, { write: true });
|
|
14
|
+
const binding = await (0, memory_sync_1.readMaterializationBinding)(flags.dir);
|
|
15
|
+
(0, memory_sync_1.assertMaterializationStore)(binding.manifest, store.id);
|
|
16
|
+
const plan = await (0, memory_sync_1.planPush)(flags.dir, { recordConflicts: !flags['dry-run'] });
|
|
17
|
+
const results = [];
|
|
18
|
+
for (const item of plan.mutations) {
|
|
19
|
+
const body = {
|
|
20
|
+
...item.input,
|
|
21
|
+
...(flags.space ? { spaceId: flags.space } : {}),
|
|
22
|
+
targetStoreId: store.id,
|
|
23
|
+
authorizationGeneration: flags['authorization-generation'] ??
|
|
24
|
+
store.mount?.authorizationGeneration ??
|
|
25
|
+
store.authorizationGeneration,
|
|
26
|
+
...(flags['privacy-approval'] ? { privacyApprovalId: flags['privacy-approval'] } : {}),
|
|
27
|
+
...(flags['dry-run'] ? { dryRun: true } : {}),
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
results.push(await (0, api_fetch_1.apiFetch)(this.endpoint(flags.agent, `/mutations/${encodeURIComponent(item.operation)}`), { method: 'POST', body }));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
let causeCode = error instanceof api_fetch_1.ApiFetchError ? error.code : undefined;
|
|
34
|
+
let causeMessage = error instanceof Error ? error.message : String(error);
|
|
35
|
+
if (error instanceof api_fetch_1.ApiFetchError) {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse(error.body || '{}');
|
|
38
|
+
causeCode = parsed.code || parsed.error || causeCode;
|
|
39
|
+
causeMessage = parsed.message || causeMessage;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Preserve the transport code/message when the body is not JSON.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const dryRun = flags['dry-run'] === true;
|
|
46
|
+
const partial = {
|
|
47
|
+
status: dryRun ? 'validation_failure' : 'partial_failure',
|
|
48
|
+
code: dryRun
|
|
49
|
+
? 'MEMORY_SYNC_DRY_RUN_VALIDATION_FAILED'
|
|
50
|
+
: 'MEMORY_SYNC_PARTIAL_PUSH_FAILED',
|
|
51
|
+
planned: plan.mutations.length,
|
|
52
|
+
committed: dryRun ? 0 : results.length,
|
|
53
|
+
validated: dryRun ? results.length : undefined,
|
|
54
|
+
remoteCommitted: !dryRun && results.length > 0,
|
|
55
|
+
failedFile: item.file,
|
|
56
|
+
retryable: true,
|
|
57
|
+
causeCode,
|
|
58
|
+
causeMessage,
|
|
59
|
+
results,
|
|
60
|
+
next: dryRun
|
|
61
|
+
? 'No remote changes were committed. Fix the failed file and rerun the dry-run.'
|
|
62
|
+
: 'Inspect the failed file, then retry with the unchanged directory. Completed items reuse stable idempotency keys.',
|
|
63
|
+
};
|
|
64
|
+
if (flags.json)
|
|
65
|
+
this.log(JSON.stringify(partial, null, 2));
|
|
66
|
+
else {
|
|
67
|
+
this.log(dryRun
|
|
68
|
+
? `Dry-run validation failed after ${results.length}/${plan.mutations.length} item(s); no remote changes were committed.`
|
|
69
|
+
: `Partial push: ${results.length}/${plan.mutations.length} remote change(s) committed before ${item.file} failed.`);
|
|
70
|
+
this.log(partial.next);
|
|
71
|
+
}
|
|
72
|
+
process.exitCode =
|
|
73
|
+
error instanceof api_fetch_1.ApiFetchError && error.status === 409
|
|
74
|
+
? 6
|
|
75
|
+
: error instanceof api_fetch_1.ApiFetchError && error.status === 403
|
|
76
|
+
? 5
|
|
77
|
+
: error instanceof api_fetch_1.ApiFetchError && error.status === 404
|
|
78
|
+
? 4
|
|
79
|
+
: 2;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let localRefresh = { status: 'not_required' };
|
|
84
|
+
if (!flags['dry-run'] && plan.mutations.length) {
|
|
85
|
+
try {
|
|
86
|
+
const snapshot = await (0, api_fetch_1.apiFetch)(this.endpoint(flags.agent, `/stores/${store.id}/sync/snapshot${this.query(flags)}`));
|
|
87
|
+
await (0, memory_sync_1.pullSnapshot)(flags.dir, snapshot);
|
|
88
|
+
localRefresh = { status: 'refreshed', cursor: snapshot.cursor };
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
localRefresh = {
|
|
92
|
+
status: 'failed',
|
|
93
|
+
remoteCommitted: true,
|
|
94
|
+
retryable: true,
|
|
95
|
+
code: 'MEMORY_SYNC_LOCAL_REFRESH_FAILED',
|
|
96
|
+
message: 'Remote Memory changes committed, but the local basis could not be refreshed. Retry this push with the unchanged files; stable idempotency keys prevent duplicate writes.',
|
|
97
|
+
cause: error instanceof Error ? error.message : String(error),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const result = {
|
|
102
|
+
changed: plan.mutations.length,
|
|
103
|
+
conflicts: plan.conflicts,
|
|
104
|
+
unrecognizedFiles: plan.unrecognizedFiles,
|
|
105
|
+
nextActions: plan.nextActions,
|
|
106
|
+
results,
|
|
107
|
+
dryRun: flags['dry-run'],
|
|
108
|
+
localRefresh,
|
|
109
|
+
};
|
|
110
|
+
this.print(result, flags.json, localRefresh.status === 'failed'
|
|
111
|
+
? `Committed ${result.changed} remote change(s), but local refresh failed. Retry the same push to recover safely.`
|
|
112
|
+
: `${flags['dry-run'] ? 'Would push' : 'Pushed'} ${result.changed} change(s); ${result.conflicts} conflict(s).`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.default = MemorySyncPush;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ScopedMemoryCommand } from '../../../lib/scoped-memory-command';
|
|
2
|
+
export default class MemorySyncResolve extends ScopedMemoryCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
conflict: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
strategy: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
content: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
'authorization-generation': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
'expected-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
'idempotency-key': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
'privacy-approval': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
'dry-run': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
17
|
+
space: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
|
+
store: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
19
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
20
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
};
|
|
22
|
+
run(): Promise<void>;
|
|
23
|
+
}
|