@kindgi/cli 0.1.4 → 0.1.5
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 +13 -7
- package/dist/build/bundle.d.ts +11 -3
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +17 -3
- package/dist/build/bundle.js.map +1 -1
- package/dist/build/defaults.d.ts +3 -1
- package/dist/build/defaults.d.ts.map +1 -1
- package/dist/build/defaults.js +44 -1
- package/dist/build/defaults.js.map +1 -1
- package/dist/build/java-image.d.ts +31 -0
- package/dist/build/java-image.d.ts.map +1 -0
- package/dist/build/java-image.js +146 -0
- package/dist/build/java-image.js.map +1 -0
- package/dist/build/pack-root.d.ts +1 -31
- package/dist/build/pack-root.d.ts.map +1 -1
- package/dist/build/pack-root.js +22 -2
- package/dist/build/pack-root.js.map +1 -1
- package/dist/build/runners.d.ts +44 -0
- package/dist/build/runners.d.ts.map +1 -1
- package/dist/build/scala-image.d.ts +21 -0
- package/dist/build/scala-image.d.ts.map +1 -0
- package/dist/build/scala-image.js +150 -0
- package/dist/build/scala-image.js.map +1 -0
- package/dist/cli-pin.d.ts +16 -0
- package/dist/cli-pin.d.ts.map +1 -0
- package/dist/cli-pin.js +66 -0
- package/dist/cli-pin.js.map +1 -0
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +9 -8
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/approvals.d.ts.map +1 -1
- package/dist/commands/approvals.js +30 -4
- package/dist/commands/approvals.js.map +1 -1
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +100 -37
- package/dist/commands/artifacts.js.map +1 -1
- package/dist/commands/auth.js +2 -2
- package/dist/commands/blocks.d.ts.map +1 -1
- package/dist/commands/blocks.js +5 -4
- package/dist/commands/blocks.js.map +1 -1
- package/dist/commands/build.d.ts +10 -2
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +109 -16
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/capabilities.d.ts.map +1 -1
- package/dist/commands/capabilities.js +37 -10
- package/dist/commands/capabilities.js.map +1 -1
- package/dist/commands/console.d.ts +21 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/console.js +87 -0
- package/dist/commands/console.js.map +1 -0
- package/dist/commands/conversations.d.ts.map +1 -1
- package/dist/commands/conversations.js +13 -2
- package/dist/commands/conversations.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +11 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +212 -40
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +14 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +356 -20
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/env-scoped.d.ts +44 -0
- package/dist/commands/env-scoped.d.ts.map +1 -0
- package/dist/commands/env-scoped.js +222 -0
- package/dist/commands/env-scoped.js.map +1 -0
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +85 -123
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/eval-runs.d.ts +9 -0
- package/dist/commands/eval-runs.d.ts.map +1 -1
- package/dist/commands/eval-runs.js +20 -19
- package/dist/commands/eval-runs.js.map +1 -1
- package/dist/commands/eval-suites.d.ts.map +1 -1
- package/dist/commands/eval-suites.js +16 -8
- package/dist/commands/eval-suites.js.map +1 -1
- package/dist/commands/exports.d.ts +3 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +82 -0
- package/dist/commands/exports.js.map +1 -0
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +6 -5
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/flows.d.ts.map +1 -1
- package/dist/commands/flows.js +2 -1
- package/dist/commands/flows.js.map +1 -1
- package/dist/commands/gate-policies.d.ts.map +1 -1
- package/dist/commands/gate-policies.js +2 -1
- package/dist/commands/gate-policies.js.map +1 -1
- package/dist/commands/guardrails.d.ts.map +1 -1
- package/dist/commands/guardrails.js +3 -2
- package/dist/commands/guardrails.js.map +1 -1
- package/dist/commands/helpers.js +5 -5
- package/dist/commands/helpers.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +14 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +254 -18
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/judge-classes.d.ts.map +1 -1
- package/dist/commands/judge-classes.js +11 -10
- package/dist/commands/judge-classes.js.map +1 -1
- package/dist/commands/judgments.d.ts.map +1 -1
- package/dist/commands/judgments.js +7 -6
- package/dist/commands/judgments.js.map +1 -1
- package/dist/commands/key.js +4 -4
- package/dist/commands/memory.d.ts.map +1 -1
- package/dist/commands/memory.js +277 -25
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/people.d.ts +3 -0
- package/dist/commands/people.d.ts.map +1 -0
- package/dist/commands/people.js +166 -0
- package/dist/commands/people.js.map +1 -0
- package/dist/commands/proposals.d.ts.map +1 -1
- package/dist/commands/proposals.js +390 -69
- package/dist/commands/proposals.js.map +1 -1
- package/dist/commands/provenance.d.ts.map +1 -1
- package/dist/commands/provenance.js +6 -7
- package/dist/commands/provenance.js.map +1 -1
- package/dist/commands/providers.d.ts.map +1 -1
- package/dist/commands/providers.js +7 -5
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/reviewers.d.ts.map +1 -1
- package/dist/commands/reviewers.js +3 -2
- package/dist/commands/reviewers.js.map +1 -1
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/runs.js +35 -15
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/schedules.d.ts +3 -0
- package/dist/commands/schedules.d.ts.map +1 -0
- package/dist/commands/schedules.js +275 -0
- package/dist/commands/schedules.js.map +1 -0
- package/dist/commands/secrets.d.ts.map +1 -1
- package/dist/commands/secrets.js +10 -11
- package/dist/commands/secrets.js.map +1 -1
- package/dist/commands/service-accounts.d.ts +3 -0
- package/dist/commands/service-accounts.d.ts.map +1 -0
- package/dist/commands/service-accounts.js +175 -0
- package/dist/commands/service-accounts.js.map +1 -0
- package/dist/commands/skills.d.ts +1 -1
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/commands/skills.js +11 -4
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sso.d.ts +6 -0
- package/dist/commands/sso.d.ts.map +1 -0
- package/dist/commands/sso.js +318 -0
- package/dist/commands/sso.js.map +1 -0
- package/dist/commands/tokens.d.ts +11 -0
- package/dist/commands/tokens.d.ts.map +1 -1
- package/dist/commands/tokens.js +144 -11
- package/dist/commands/tokens.js.map +1 -1
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +4 -3
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/unwired.d.ts.map +1 -1
- package/dist/commands/unwired.js +1 -30
- package/dist/commands/unwired.js.map +1 -1
- package/dist/commands/upgrade.d.ts +11 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +160 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/context.d.ts +7 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/dev/defaults.d.ts +28 -11
- package/dist/dev/defaults.d.ts.map +1 -1
- package/dist/dev/defaults.js +114 -35
- package/dist/dev/defaults.js.map +1 -1
- package/dist/dev/google-credentials.d.ts +50 -0
- package/dist/dev/google-credentials.d.ts.map +1 -0
- package/dist/dev/google-credentials.js +157 -0
- package/dist/dev/google-credentials.js.map +1 -0
- package/dist/dev/java-builder.d.ts +56 -0
- package/dist/dev/java-builder.d.ts.map +1 -0
- package/dist/dev/java-builder.js +204 -0
- package/dist/dev/java-builder.js.map +1 -0
- package/dist/dev/jvm-run-files.d.ts +29 -0
- package/dist/dev/jvm-run-files.d.ts.map +1 -0
- package/dist/dev/jvm-run-files.js +94 -0
- package/dist/dev/jvm-run-files.js.map +1 -0
- package/dist/dev/lines.d.ts +13 -0
- package/dist/dev/lines.d.ts.map +1 -0
- package/dist/dev/lines.js +24 -0
- package/dist/dev/lines.js.map +1 -0
- package/dist/dev/log-view.d.ts +116 -0
- package/dist/dev/log-view.d.ts.map +1 -0
- package/dist/dev/log-view.js +233 -0
- package/dist/dev/log-view.js.map +1 -0
- package/dist/dev/pack-code.d.ts +79 -4
- package/dist/dev/pack-code.d.ts.map +1 -1
- package/dist/dev/pack-code.js +262 -3
- package/dist/dev/pack-code.js.map +1 -1
- package/dist/dev/pack-env.d.ts.map +1 -1
- package/dist/dev/pack-env.js +4 -0
- package/dist/dev/pack-env.js.map +1 -1
- package/dist/dev/pack-service.d.ts +11 -1
- package/dist/dev/pack-service.d.ts.map +1 -1
- package/dist/dev/pack-service.js +56 -20
- package/dist/dev/pack-service.js.map +1 -1
- package/dist/dev/paths.d.ts +6 -0
- package/dist/dev/paths.d.ts.map +1 -1
- package/dist/dev/paths.js +8 -0
- package/dist/dev/paths.js.map +1 -1
- package/dist/dev/project-database.js +1 -1
- package/dist/dev/project-database.js.map +1 -1
- package/dist/dev/runners.d.ts +35 -9
- package/dist/dev/runners.d.ts.map +1 -1
- package/dist/dev/runtime-container.d.ts +10 -2
- package/dist/dev/runtime-container.d.ts.map +1 -1
- package/dist/dev/runtime-container.js +48 -20
- package/dist/dev/runtime-container.js.map +1 -1
- package/dist/dev/runtime-env.d.ts +10 -0
- package/dist/dev/runtime-env.d.ts.map +1 -1
- package/dist/dev/runtime-env.js +8 -4
- package/dist/dev/runtime-env.js.map +1 -1
- package/dist/dev/runtime-image.d.ts +1 -1
- package/dist/dev/runtime-image.js +1 -1
- package/dist/dev/scala-builder.d.ts +72 -0
- package/dist/dev/scala-builder.d.ts.map +1 -0
- package/dist/dev/scala-builder.js +347 -0
- package/dist/dev/scala-builder.js.map +1 -0
- package/dist/env/project-env.d.ts.map +1 -1
- package/dist/env/project-env.js +3 -1
- package/dist/env/project-env.js.map +1 -1
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/init/augment-scaffolder.js +1 -1
- package/dist/init/augment-scaffolder.js.map +1 -1
- package/dist/init/dependency-specs.d.ts +26 -0
- package/dist/init/dependency-specs.d.ts.map +1 -1
- package/dist/init/dependency-specs.js +38 -0
- package/dist/init/dependency-specs.js.map +1 -1
- package/dist/init/java-augment.d.ts +24 -0
- package/dist/init/java-augment.d.ts.map +1 -0
- package/dist/init/java-augment.js +198 -0
- package/dist/init/java-augment.js.map +1 -0
- package/dist/init/mode-detect.d.ts +2 -2
- package/dist/init/mode-detect.d.ts.map +1 -1
- package/dist/init/mode-detect.js +12 -1
- package/dist/init/mode-detect.js.map +1 -1
- package/dist/init/python-augment.js +1 -1
- package/dist/init/python-augment.js.map +1 -1
- package/dist/init/scala-augment.d.ts +23 -0
- package/dist/init/scala-augment.d.ts.map +1 -0
- package/dist/init/scala-augment.js +213 -0
- package/dist/init/scala-augment.js.map +1 -0
- package/dist/init/template-files.d.ts +40 -2
- package/dist/init/template-files.d.ts.map +1 -1
- package/dist/init/template-files.js +56 -5
- package/dist/init/template-files.js.map +1 -1
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -2
- package/dist/main.js.map +1 -1
- package/dist/open-url.d.ts +15 -0
- package/dist/open-url.d.ts.map +1 -0
- package/dist/open-url.js +41 -0
- package/dist/open-url.js.map +1 -0
- package/dist/package-manager.d.ts +10 -3
- package/dist/package-manager.d.ts.map +1 -1
- package/dist/package-manager.js +19 -1
- package/dist/package-manager.js.map +1 -1
- package/dist/providers/presets/anthropic.json +11 -3
- package/dist/sdk-skills/kindgi-authoring-agents/SKILL.md +30 -2
- package/dist/sdk-skills/kindgi-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-authoring-guardrails/SKILL.md +47 -3
- package/dist/sdk-skills/kindgi-authoring-mcp-servers/SKILL.md +7 -5
- package/dist/sdk-skills/kindgi-authoring-providers/SKILL.md +40 -15
- package/dist/sdk-skills/kindgi-authoring-tools/SKILL.md +66 -2
- package/dist/sdk-skills/kindgi-framework-feedback/SKILL.md +5 -4
- package/dist/sdk-skills/kindgi-getting-started/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-java-authoring-agents/SKILL.md +220 -0
- package/dist/sdk-skills/kindgi-java-authoring-flows/SKILL.md +390 -0
- package/dist/sdk-skills/kindgi-java-authoring-guardrails/SKILL.md +209 -0
- package/dist/sdk-skills/kindgi-java-authoring-tools/SKILL.md +334 -0
- package/dist/sdk-skills/kindgi-java-getting-started/SKILL.md +270 -0
- package/dist/sdk-skills/kindgi-python-authoring-agents/SKILL.md +25 -3
- package/dist/sdk-skills/kindgi-python-authoring-flows/SKILL.md +1 -1
- package/dist/sdk-skills/kindgi-python-authoring-guardrails/SKILL.md +10 -3
- package/dist/sdk-skills/kindgi-python-authoring-tools/SKILL.md +45 -6
- package/dist/sdk-skills/kindgi-python-getting-started/SKILL.md +2 -2
- package/dist/sdk-skills/kindgi-scala-authoring-agents/SKILL.md +217 -0
- package/dist/sdk-skills/kindgi-scala-authoring-flows/SKILL.md +357 -0
- package/dist/sdk-skills/kindgi-scala-authoring-guardrails/SKILL.md +199 -0
- package/dist/sdk-skills/kindgi-scala-authoring-tools/SKILL.md +302 -0
- package/dist/sdk-skills/kindgi-scala-getting-started/SKILL.md +302 -0
- package/dist/templates/java/.mvn/wrapper/maven-wrapper.properties +3 -0
- package/dist/templates/java/AGENTS.md +31 -0
- package/dist/templates/java/README.md.tmpl +69 -0
- package/dist/templates/java/gitignore +9 -0
- package/dist/templates/java/kindgi.config.json.tmpl +8 -0
- package/dist/templates/java/kindgiw +33 -0
- package/dist/templates/java/kindgiw.cmd +28 -0
- package/dist/templates/java/mvnw +295 -0
- package/dist/templates/java/pom.xml.tmpl +65 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/agents/EchoAgent.java.tmpl +27 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/flows/EchoFlow.java.tmpl +18 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/guardrails/ResponseNotEmpty.java.tmpl +28 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/tools/Echo.java.tmpl +22 -0
- package/dist/templates/java/src/main/java/__PACKAGE__/tools/Greet.java.tmpl +23 -0
- package/dist/templates/java/src/test/java/__PACKAGE__/ToolsTest.java.tmpl +30 -0
- package/dist/templates/minimal/README.md.tmpl +6 -12
- package/dist/templates/python/README.md.tmpl +4 -4
- package/dist/templates/sample/README.md.tmpl +5 -11
- package/dist/templates/scala/AGENTS.md +32 -0
- package/dist/templates/scala/README.md.tmpl +75 -0
- package/dist/templates/scala/build.sbt.tmpl +16 -0
- package/dist/templates/scala/gitignore +13 -0
- package/dist/templates/scala/kindgi.config.json.tmpl +8 -0
- package/dist/templates/scala/project/build.properties +1 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/agents/EchoAgent.scala.tmpl +23 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/flows/EchoFlow.scala.tmpl +16 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/guardrails/ResponseNotEmpty.scala.tmpl +21 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/tools/Echo.scala.tmpl +16 -0
- package/dist/templates/scala/src/main/scala/__PACKAGE__/tools/Greet.scala.tmpl +17 -0
- package/dist/templates/scala/src/test/scala/__PACKAGE__/ToolsSuite.scala.tmpl +23 -0
- package/package.json +13 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
import { UsageError } from '../errors.js';
|
|
3
4
|
import { integerFlag, listFlag, requiredPositional, runSdk, stringFlag } from './helpers.js';
|
|
4
5
|
const SCOPE_FLAGS = {
|
|
5
6
|
tenant: { type: 'boolean', description: 'The whole tenant.' },
|
|
@@ -15,19 +16,19 @@ function scopeFromFlags(ctx, required) {
|
|
|
15
16
|
const projectId = stringFlag(ctx, 'project');
|
|
16
17
|
const agentId = stringFlag(ctx, 'agent');
|
|
17
18
|
if (tenant && (projectId !== undefined || agentId !== undefined)) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new UsageError('--tenant cannot be combined with --project or --agent');
|
|
19
20
|
}
|
|
20
21
|
if (tenant)
|
|
21
22
|
return { kind: 'tenant' };
|
|
22
23
|
if (agentId !== undefined) {
|
|
23
24
|
if (projectId === undefined)
|
|
24
|
-
throw new
|
|
25
|
+
throw new UsageError('--agent needs --project');
|
|
25
26
|
return { kind: 'agent', projectId, agentId };
|
|
26
27
|
}
|
|
27
28
|
if (projectId !== undefined)
|
|
28
29
|
return { kind: 'project', projectId };
|
|
29
30
|
if (required)
|
|
30
|
-
throw new
|
|
31
|
+
throw new UsageError('Give a scope: --tenant, --project=<id>, or --agent=<id> --project=<id>');
|
|
31
32
|
return undefined;
|
|
32
33
|
}
|
|
33
34
|
const REVIEWER_ROLES = ['standard', 'senior', 'admin'];
|
|
@@ -53,12 +54,12 @@ const ASSERTABLE_USAGE = '[--min-reviewer-role=standard|senior|admin] [--princip
|
|
|
53
54
|
function assertableByFromFlags(ctx) {
|
|
54
55
|
const role = stringFlag(ctx, 'min-reviewer-role');
|
|
55
56
|
if (role !== undefined && !REVIEWER_ROLES.includes(role)) {
|
|
56
|
-
throw new
|
|
57
|
+
throw new UsageError(`--min-reviewer-role must be one of ${REVIEWER_ROLES.join(', ')}, got "${role}"`);
|
|
57
58
|
}
|
|
58
59
|
const kinds = listFlag(ctx, 'principal-kind');
|
|
59
60
|
for (const kind of kinds) {
|
|
60
61
|
if (!PRINCIPAL_KINDS.includes(kind)) {
|
|
61
|
-
throw new
|
|
62
|
+
throw new UsageError(`--principal-kind must be user or service, got "${kind}"`);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
const ids = listFlag(ctx, 'principal-id');
|
|
@@ -78,7 +79,7 @@ function weightFlag(ctx) {
|
|
|
78
79
|
return undefined;
|
|
79
80
|
const n = Number(raw);
|
|
80
81
|
if (!Number.isFinite(n) || n < 0)
|
|
81
|
-
throw new
|
|
82
|
+
throw new UsageError(`--weight must be a number of 0 or more, got '${raw}'`);
|
|
82
83
|
return n;
|
|
83
84
|
}
|
|
84
85
|
const list = {
|
|
@@ -123,10 +124,10 @@ const add = {
|
|
|
123
124
|
run: (ctx) => runSdk(ctx, 'judge-classes add', async () => {
|
|
124
125
|
const name = stringFlag(ctx, 'name');
|
|
125
126
|
if (name === undefined)
|
|
126
|
-
throw new
|
|
127
|
+
throw new UsageError('--name=<name> is required');
|
|
127
128
|
const weight = weightFlag(ctx);
|
|
128
129
|
if (weight === undefined)
|
|
129
|
-
throw new
|
|
130
|
+
throw new UsageError('--weight=<w> is required');
|
|
130
131
|
const scope = scopeFromFlags(ctx, true);
|
|
131
132
|
const description = stringFlag(ctx, 'description');
|
|
132
133
|
const assertableBy = assertableByFromFlags(ctx);
|
|
@@ -160,11 +161,11 @@ const set = {
|
|
|
160
161
|
const restricted = assertableByFromFlags(ctx);
|
|
161
162
|
const unrestricted = ctx.options.unrestricted === true;
|
|
162
163
|
if (restricted !== undefined && unrestricted) {
|
|
163
|
-
throw new
|
|
164
|
+
throw new UsageError('--unrestricted cannot be combined with the restriction flags');
|
|
164
165
|
}
|
|
165
166
|
const assertableBy = unrestricted ? null : restricted;
|
|
166
167
|
if (weight === undefined && description === undefined && assertableBy === undefined) {
|
|
167
|
-
throw new
|
|
168
|
+
throw new UsageError('Give --weight, --description, a restriction flag, or --unrestricted');
|
|
168
169
|
}
|
|
169
170
|
return await ctx.client().judgeClasses.update(id, {
|
|
170
171
|
...(weight !== undefined && { weight }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judge-classes.js","sourceRoot":"","sources":["../../src/commands/judge-classes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAKjC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG7F,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE;IAC7D,OAAO,EAAE;QACP,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,gEAAgE;KAC9E;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sCAAsC,EAAE;CACtE,CAAC;AAEX,wFAAwF;AACxF,SAAS,cAAc,CAAC,GAAmB,EAAE,QAAiB;IAC5D,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,IAAI,MAAM,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"judge-classes.js","sourceRoot":"","sources":["../../src/commands/judge-classes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAKjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG7F,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE;IAC7D,OAAO,EAAE;QACP,I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AAW,EAAE,gFAAgF;IAC7F,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC;CACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judgments.d.ts","sourceRoot":"","sources":["../../src/commands/judgments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"judgments.d.ts","sourceRoot":"","sources":["../../src/commands/judgments.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAuKvD,eAAO,MAAM,gBAAgB,EAAE,OAK9B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
import { UsageError } from '../errors.js';
|
|
3
4
|
import { integerFlag, requiredPositional, runSdk, stringFlag } from './helpers.js';
|
|
4
5
|
const VERDICTS = ['yes', 'no'];
|
|
5
6
|
/** The string flags given, under their request field names (`{ class: 'judgeClassId' }`). */
|
|
@@ -43,17 +44,17 @@ const add = {
|
|
|
43
44
|
run: (ctx) => runSdk(ctx, 'judgments add', async () => {
|
|
44
45
|
const runId = stringFlag(ctx, 'run');
|
|
45
46
|
if (runId === undefined)
|
|
46
|
-
throw new
|
|
47
|
+
throw new UsageError('--run=<run-id> is required');
|
|
47
48
|
const key = stringFlag(ctx, 'item');
|
|
48
49
|
if (key === undefined)
|
|
49
|
-
throw new
|
|
50
|
+
throw new UsageError('--item=<key> is required');
|
|
50
51
|
const yes = ctx.options.yes === true;
|
|
51
52
|
const no = ctx.options.no === true;
|
|
52
53
|
if (yes === no)
|
|
53
|
-
throw new
|
|
54
|
+
throw new UsageError('Give exactly one of --yes or --no');
|
|
54
55
|
const rank = integerFlag(ctx, 'rank');
|
|
55
56
|
if (rank !== undefined && rank < 0)
|
|
56
|
-
throw new
|
|
57
|
+
throw new UsageError('--rank must be 0 or more');
|
|
57
58
|
const pointer = ctx.options.pointer;
|
|
58
59
|
return await ctx.client().judgments.create({
|
|
59
60
|
runId,
|
|
@@ -104,11 +105,11 @@ const list = {
|
|
|
104
105
|
run: (ctx) => runSdk(ctx, 'judgments list', async () => {
|
|
105
106
|
if (stringFlag(ctx, 'agent-version') !== undefined &&
|
|
106
107
|
stringFlag(ctx, 'agent') === undefined) {
|
|
107
|
-
throw new
|
|
108
|
+
throw new UsageError('--agent-version needs --agent');
|
|
108
109
|
}
|
|
109
110
|
const verdict = stringFlag(ctx, 'verdict');
|
|
110
111
|
if (verdict !== undefined && !VERDICTS.includes(verdict)) {
|
|
111
|
-
throw new
|
|
112
|
+
throw new UsageError(`--verdict must be one of ${VERDICTS.join(', ')}, got "${verdict}"`);
|
|
112
113
|
}
|
|
113
114
|
const projectId = stringFlag(ctx, 'project');
|
|
114
115
|
const limit = integerFlag(ctx, 'limit');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judgments.js","sourceRoot":"","sources":["../../src/commands/judgments.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAGjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnF,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,IAAI,CAAU,CAAC;AAExC,6FAA6F;AAC7F,SAAS,UAAU,CACjB,GAAmB,EACnB,MAAmC;IAEnC,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC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ANGED
|
@@ -78,7 +78,7 @@ const createCmd = {
|
|
|
78
78
|
run: async (ctx) => {
|
|
79
79
|
const idCheck = validateKeyId(ctx.positionals[0]);
|
|
80
80
|
if (!idCheck.ok) {
|
|
81
|
-
return { kind: 'error', stderr: `${idCheck.error}\n`, exitCode:
|
|
81
|
+
return { kind: 'error', stderr: `${idCheck.error}\n`, exitCode: 2 };
|
|
82
82
|
}
|
|
83
83
|
const keyId = idCheck.id;
|
|
84
84
|
const runnersOutcome = pickRunners(ctx);
|
|
@@ -168,7 +168,7 @@ const exportCmd = {
|
|
|
168
168
|
run: async (ctx) => {
|
|
169
169
|
const idCheck = validateKeyId(ctx.positionals[0]);
|
|
170
170
|
if (!idCheck.ok) {
|
|
171
|
-
return { kind: 'error', stderr: `${idCheck.error}\n`, exitCode:
|
|
171
|
+
return { kind: 'error', stderr: `${idCheck.error}\n`, exitCode: 2 };
|
|
172
172
|
}
|
|
173
173
|
const keyId = idCheck.id;
|
|
174
174
|
const formatFlag = ctx.options.format;
|
|
@@ -177,7 +177,7 @@ const exportCmd = {
|
|
|
177
177
|
return {
|
|
178
178
|
kind: 'error',
|
|
179
179
|
stderr: `Unknown --format: ${formatInput}. Available: ${AVAILABLE_FORMATS.join(', ')}.\n`,
|
|
180
|
-
exitCode:
|
|
180
|
+
exitCode: 2,
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
const format = formatInput;
|
|
@@ -332,7 +332,7 @@ const trustCmd = {
|
|
|
332
332
|
run: async (ctx) => {
|
|
333
333
|
const idCheck = validateKeyId(ctx.positionals[0]);
|
|
334
334
|
if (!idCheck.ok) {
|
|
335
|
-
return { kind: 'error', stderr: `${idCheck.error}\n`, exitCode:
|
|
335
|
+
return { kind: 'error', stderr: `${idCheck.error}\n`, exitCode: 2 };
|
|
336
336
|
}
|
|
337
337
|
const keyId = idCheck.id;
|
|
338
338
|
const runnersOutcome = pickRunners(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/commands/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/commands/memory.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,YAAY,CAAC;AAmevD,eAAO,MAAM,aAAa,EAAE,OAM3B,CAAC"}
|
package/dist/commands/memory.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
-
import {
|
|
3
|
+
import { writeFile } from 'node:fs/promises';
|
|
4
|
+
import { UsageError } from '../errors.js';
|
|
5
|
+
import { integerFlag, readJsonInput, requiredPositional, runSdk, stringFlag, truncateCell, } from './helpers.js';
|
|
6
|
+
const contentCell = (f) => f.content !== undefined ? truncateCell(JSON.stringify(f.content), 60) : '';
|
|
4
7
|
/** `memory facts list --table`. */
|
|
5
8
|
const FACTS_TABLE = {
|
|
6
9
|
rows: (page) => page.data,
|
|
@@ -8,32 +11,55 @@ const FACTS_TABLE = {
|
|
|
8
11
|
{ header: 'ID', get: (f) => String(f.id) },
|
|
9
12
|
{ header: 'TYPE', get: (f) => f.type },
|
|
10
13
|
{ header: 'VERSION', get: (f) => String(f.version) },
|
|
14
|
+
{ header: 'TRUST', get: (f) => f.trust ?? 'asserted' },
|
|
15
|
+
{ header: 'CREATED', get: (f) => String(f.createdAt) },
|
|
16
|
+
{ header: 'CONTENT', get: contentCell },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
/** `memory facts revisions --table`: newest first, with why each one stopped being current. */
|
|
20
|
+
const REVISIONS_TABLE = {
|
|
21
|
+
rows: (revisions) => revisions,
|
|
22
|
+
columns: [
|
|
23
|
+
{ header: 'VERSION', get: (f) => String(f.version) },
|
|
24
|
+
{ header: 'TRUST', get: (f) => f.trust ?? 'asserted' },
|
|
11
25
|
{ header: 'CREATED', get: (f) => String(f.createdAt) },
|
|
12
26
|
{
|
|
13
|
-
header: '
|
|
14
|
-
get: (f) =>
|
|
27
|
+
header: 'ENDED',
|
|
28
|
+
get: (f) => f.invalidatedAt === undefined
|
|
29
|
+
? 'current'
|
|
30
|
+
: `${f.invalidationReason ?? 'ended'} ${String(f.invalidatedAt)} by ${f.invalidatedBy ?? '?'}`,
|
|
15
31
|
},
|
|
32
|
+
{ header: 'CONTENT', get: contentCell },
|
|
16
33
|
],
|
|
17
34
|
};
|
|
35
|
+
const AS_OF_OPTION = {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Memory as it stood at this time (ISO 8601), deleted and superseded facts included.',
|
|
38
|
+
};
|
|
39
|
+
const EXPECT_VERSION_OPTION = {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Only if the fact is still at this revision (its `version`); if someone changed it first, nothing changes and the command fails with `fact-changed`.',
|
|
42
|
+
};
|
|
18
43
|
/** A JSON object from inline JSON or `@<file>`, or an error naming the flag. */
|
|
19
44
|
async function jsonObjectFlag(text, flag) {
|
|
20
45
|
const value = await readJsonInput(text);
|
|
21
46
|
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
22
|
-
throw new
|
|
47
|
+
throw new UsageError(`--${flag} must be a JSON object`);
|
|
23
48
|
}
|
|
24
49
|
return value;
|
|
25
50
|
}
|
|
26
51
|
const factsList = {
|
|
27
52
|
kind: 'leaf',
|
|
28
53
|
name: 'list',
|
|
29
|
-
description: 'List memory facts, the
|
|
30
|
-
usage: 'kindgi memory facts list [--type=<type>] [--scope=<json-or-@file>] [--limit=<n>] [--cursor=<c>]',
|
|
54
|
+
description: 'List the memory facts you may see, the current revision of each.',
|
|
55
|
+
usage: 'kindgi memory facts list [--type=<type>] [--scope=<json-or-@file>] [--as-of=<time>] [--limit=<n>] [--cursor=<c>]',
|
|
31
56
|
optionSpec: {
|
|
32
57
|
type: { type: 'string', description: 'Only the facts of this type.' },
|
|
33
58
|
scope: {
|
|
34
59
|
type: 'string',
|
|
35
|
-
description: 'Only the facts in this scope, as inline JSON or `@<file>`: any of `userId`, `orgId`, `projectId`, `threadId`, `sessionId`; every key given must match.',
|
|
60
|
+
description: 'Only the facts in this scope, as inline JSON or `@<file>`: any of `userId`, `orgId`, `projectId`, `threadId`, `sessionId`, `participantId`; every key given must match.',
|
|
36
61
|
},
|
|
62
|
+
'as-of': AS_OF_OPTION,
|
|
37
63
|
limit: { type: 'string', description: 'The most facts to return (default 25, at most 100).' },
|
|
38
64
|
cursor: {
|
|
39
65
|
type: 'string',
|
|
@@ -46,9 +72,11 @@ const factsList = {
|
|
|
46
72
|
const scope = scopeText === undefined ? undefined : await jsonObjectFlag(scopeText, 'scope');
|
|
47
73
|
const limit = integerFlag(ctx, 'limit');
|
|
48
74
|
const cursor = stringFlag(ctx, 'cursor');
|
|
75
|
+
const asOf = stringFlag(ctx, 'as-of');
|
|
49
76
|
return await ctx.client().memory.facts.list({
|
|
50
77
|
...(type !== undefined && { type }),
|
|
51
78
|
...(scope !== undefined && { scope }),
|
|
79
|
+
...(asOf !== undefined && { asOf }),
|
|
52
80
|
...(limit !== undefined && { limit }),
|
|
53
81
|
...(cursor !== undefined && { cursor: cursor }),
|
|
54
82
|
});
|
|
@@ -57,13 +85,35 @@ const factsList = {
|
|
|
57
85
|
const factsGet = {
|
|
58
86
|
kind: 'leaf',
|
|
59
87
|
name: 'get',
|
|
60
|
-
description: 'A memory fact by id
|
|
61
|
-
usage: 'kindgi memory facts get <fact-id>',
|
|
88
|
+
description: 'A memory fact by id: its current revision, one revision, or as it stood then.',
|
|
89
|
+
usage: 'kindgi memory facts get <fact-id> [--revision=<n>] [--as-of=<time>]',
|
|
90
|
+
optionSpec: {
|
|
91
|
+
revision: { type: 'string', description: 'This revision (its `version`), current or not.' },
|
|
92
|
+
'as-of': AS_OF_OPTION,
|
|
93
|
+
},
|
|
62
94
|
run: (ctx) => runSdk(ctx, 'memory facts get', async () => {
|
|
63
95
|
const id = requiredPositional(ctx, 0, 'fact-id');
|
|
64
|
-
|
|
96
|
+
const version = integerFlag(ctx, 'revision');
|
|
97
|
+
const asOf = stringFlag(ctx, 'as-of');
|
|
98
|
+
const options = {
|
|
99
|
+
...(version !== undefined && { version }),
|
|
100
|
+
...(asOf !== undefined && { asOf }),
|
|
101
|
+
};
|
|
102
|
+
return Object.keys(options).length === 0
|
|
103
|
+
? await ctx.client().memory.facts.read(id)
|
|
104
|
+
: await ctx.client().memory.facts.read(id, options);
|
|
65
105
|
}),
|
|
66
106
|
};
|
|
107
|
+
const factsRevisions = {
|
|
108
|
+
kind: 'leaf',
|
|
109
|
+
name: 'revisions',
|
|
110
|
+
description: "A memory fact's revisions, newest first: who changed or deleted it, when and why.",
|
|
111
|
+
usage: 'kindgi memory facts revisions <fact-id>',
|
|
112
|
+
run: (ctx) => runSdk(ctx, 'memory facts revisions', async () => {
|
|
113
|
+
const id = requiredPositional(ctx, 0, 'fact-id');
|
|
114
|
+
return await ctx.client().memory.facts.revisions(id);
|
|
115
|
+
}, REVISIONS_TABLE),
|
|
116
|
+
};
|
|
67
117
|
const factsWrite = {
|
|
68
118
|
kind: 'leaf',
|
|
69
119
|
name: 'write',
|
|
@@ -72,17 +122,17 @@ const factsWrite = {
|
|
|
72
122
|
optionSpec: {
|
|
73
123
|
input: {
|
|
74
124
|
type: 'string',
|
|
75
|
-
description: 'The fact as inline JSON or `@<file>`: its `type` and `content`, and optionally `scope` (default: your tenant; narrow it with `userId`, `orgId`, `projectId`, `threadId`, `sessionId`
|
|
125
|
+
description: 'The fact as inline JSON or `@<file>`: its `type` and `content`, and optionally `scope` (default: your tenant; narrow it with `userId`, `orgId`, `projectId`, `threadId`, `sessionId`, or an app\'s end user with `projectId` and `participantId`), `retention` (`keepDays`, `keepUntil`, `legalHold`), `subjects` (whom it is about: `[{"kind":"participant","id":"…"}]`) and `validFrom`/`validUntil`/`observedAt`. Required.',
|
|
76
126
|
},
|
|
77
127
|
},
|
|
78
128
|
run: (ctx) => runSdk(ctx, 'memory facts write', async () => {
|
|
79
129
|
const inputText = stringFlag(ctx, 'input');
|
|
80
130
|
if (inputText === undefined)
|
|
81
|
-
throw new
|
|
131
|
+
throw new UsageError('--input=<json-or-@file> is required');
|
|
82
132
|
const input = (await jsonObjectFlag(inputText, 'input'));
|
|
83
133
|
const scope = input.scope ?? {};
|
|
84
134
|
if (scope === null || typeof scope !== 'object' || Array.isArray(scope)) {
|
|
85
|
-
throw new
|
|
135
|
+
throw new UsageError('--input `scope` must be a JSON object');
|
|
86
136
|
}
|
|
87
137
|
const client = ctx.client();
|
|
88
138
|
// The API asks for the scope's tenant, which can only be the caller's.
|
|
@@ -99,42 +149,244 @@ const factsWrite = {
|
|
|
99
149
|
const factsSupersede = {
|
|
100
150
|
kind: 'leaf',
|
|
101
151
|
name: 'supersede',
|
|
102
|
-
description: '
|
|
103
|
-
usage: 'kindgi memory facts supersede <fact-id> --input=<json-or-@file>',
|
|
152
|
+
description: "Change a memory fact's content: writes its next revision (same id). Prints the new revision.",
|
|
153
|
+
usage: 'kindgi memory facts supersede <fact-id> --input=<json-or-@file> [--expect-version=<n>]',
|
|
104
154
|
optionSpec: {
|
|
105
155
|
input: {
|
|
106
156
|
type: 'string',
|
|
107
|
-
description: '
|
|
157
|
+
description: 'The next revision as inline JSON or `@<file>`: its `content`, and optionally `retention`, `subjects` and `validFrom`/`validUntil`/`observedAt` (absent ones keep their current values). Its type and scope stay. Required.',
|
|
108
158
|
},
|
|
159
|
+
'expect-version': EXPECT_VERSION_OPTION,
|
|
109
160
|
},
|
|
110
161
|
run: (ctx) => runSdk(ctx, 'memory facts supersede', async () => {
|
|
111
|
-
requiredPositional(ctx, 0, 'fact-id');
|
|
112
|
-
|
|
162
|
+
const id = requiredPositional(ctx, 0, 'fact-id');
|
|
163
|
+
const inputText = stringFlag(ctx, 'input');
|
|
164
|
+
if (inputText === undefined)
|
|
165
|
+
throw new UsageError('--input=<json-or-@file> is required');
|
|
166
|
+
const input = (await jsonObjectFlag(inputText, 'input'));
|
|
167
|
+
if (!('content' in input))
|
|
168
|
+
throw new UsageError('--input needs `content`: the next revision');
|
|
169
|
+
const expectVersion = integerFlag(ctx, 'expect-version');
|
|
170
|
+
// The rest is the server's to check.
|
|
171
|
+
return await ctx.client().memory.facts.supersede(id, {
|
|
172
|
+
...input,
|
|
173
|
+
content: input.content,
|
|
174
|
+
...(expectVersion !== undefined && { expectVersion }),
|
|
175
|
+
});
|
|
113
176
|
}),
|
|
114
177
|
};
|
|
178
|
+
const factsDelete = {
|
|
179
|
+
kind: 'leaf',
|
|
180
|
+
name: 'delete',
|
|
181
|
+
description: 'Delete a memory fact: agents and reads no longer see it; its history stays until retention removes it. Prints the closed revision.',
|
|
182
|
+
usage: 'kindgi memory facts delete <fact-id> [--expect-version=<n>]',
|
|
183
|
+
optionSpec: { 'expect-version': EXPECT_VERSION_OPTION },
|
|
184
|
+
run: (ctx) => runSdk(ctx, 'memory facts delete', async () => {
|
|
185
|
+
const id = requiredPositional(ctx, 0, 'fact-id');
|
|
186
|
+
const expectVersion = integerFlag(ctx, 'expect-version');
|
|
187
|
+
return expectVersion === undefined
|
|
188
|
+
? await ctx.client().memory.facts.delete(id)
|
|
189
|
+
: await ctx.client().memory.facts.delete(id, { expectVersion });
|
|
190
|
+
}),
|
|
191
|
+
};
|
|
192
|
+
const factsVerify = {
|
|
193
|
+
kind: 'leaf',
|
|
194
|
+
name: 'verify',
|
|
195
|
+
description: 'Mark a memory fact verified: you checked it. Prints the new revision (`trust: verified`).',
|
|
196
|
+
usage: 'kindgi memory facts verify <fact-id> [--expect-version=<n>]',
|
|
197
|
+
optionSpec: { 'expect-version': EXPECT_VERSION_OPTION },
|
|
198
|
+
run: (ctx) => runSdk(ctx, 'memory facts verify', async () => {
|
|
199
|
+
const id = requiredPositional(ctx, 0, 'fact-id');
|
|
200
|
+
const expectVersion = integerFlag(ctx, 'expect-version');
|
|
201
|
+
return expectVersion === undefined
|
|
202
|
+
? await ctx.client().memory.facts.verify(id)
|
|
203
|
+
: await ctx.client().memory.facts.verify(id, { expectVersion });
|
|
204
|
+
}),
|
|
205
|
+
};
|
|
206
|
+
/** `memory facts retrieve --table`: best first. */
|
|
207
|
+
const HITS_TABLE = {
|
|
208
|
+
rows: (hits) => hits,
|
|
209
|
+
columns: [
|
|
210
|
+
{ header: 'ID', get: (h) => String(h.fact.id) },
|
|
211
|
+
{ header: 'TYPE', get: (h) => h.fact.type },
|
|
212
|
+
{ header: 'TRUST', get: (h) => h.fact.trust ?? 'asserted' },
|
|
213
|
+
{ header: 'SCORE', get: (h) => (h.score === undefined ? '' : h.score.toFixed(4)) },
|
|
214
|
+
{ header: 'CONTENT', get: (h) => contentCell(h.fact) },
|
|
215
|
+
],
|
|
216
|
+
};
|
|
115
217
|
const factsRetrieve = {
|
|
116
218
|
kind: 'leaf',
|
|
117
219
|
name: 'retrieve',
|
|
118
|
-
description: '
|
|
220
|
+
description: 'Search the memory facts you may see: newest first, by keyword, by meaning, or both fused by rank.',
|
|
119
221
|
usage: 'kindgi memory facts retrieve --query=<json-or-@file>',
|
|
120
222
|
optionSpec: {
|
|
121
223
|
query: {
|
|
122
224
|
type: 'string',
|
|
123
|
-
description: 'The retrieval as inline JSON or `@<file>`: a `mode` (`list`, `keyword`, `semantic` or `both`), and optionally `query
|
|
225
|
+
description: 'The retrieval as inline JSON or `@<file>`: a `mode` (`list`, `keyword`, `semantic` or `both`), and optionally `query` (required for a search), `type`, `scope` and `limit`. `semantic` and `both` need embeddings on the runtime (`KINDGI_MEMORY_EMBEDDINGS`). Required.',
|
|
124
226
|
},
|
|
125
227
|
},
|
|
126
|
-
run: (ctx) => runSdk(ctx, 'memory facts retrieve', async () =>
|
|
228
|
+
run: (ctx) => runSdk(ctx, 'memory facts retrieve', async () => {
|
|
229
|
+
const text = stringFlag(ctx, 'query');
|
|
230
|
+
if (text === undefined)
|
|
231
|
+
throw new UsageError('--query=<json-or-@file> is required');
|
|
232
|
+
const input = (await jsonObjectFlag(text, 'query'));
|
|
233
|
+
// The mode and the rest are the server's to check.
|
|
234
|
+
return await ctx
|
|
235
|
+
.client()
|
|
236
|
+
.memory.search({ ...input, mode: input.mode });
|
|
237
|
+
}, HITS_TABLE),
|
|
127
238
|
};
|
|
128
239
|
const factsGroup = {
|
|
129
240
|
kind: 'group',
|
|
130
241
|
name: 'facts',
|
|
131
|
-
description: 'Memory facts: list, get, write.',
|
|
132
|
-
subcommands: [
|
|
242
|
+
description: 'Memory facts: list, get, write, supersede, delete, verify, revisions.',
|
|
243
|
+
subcommands: [
|
|
244
|
+
factsList,
|
|
245
|
+
factsGet,
|
|
246
|
+
factsRevisions,
|
|
247
|
+
factsWrite,
|
|
248
|
+
factsSupersede,
|
|
249
|
+
factsDelete,
|
|
250
|
+
factsVerify,
|
|
251
|
+
factsRetrieve,
|
|
252
|
+
],
|
|
253
|
+
};
|
|
254
|
+
/** `memory erasures list --table`. */
|
|
255
|
+
const ERASURES_TABLE = {
|
|
256
|
+
rows: (page) => page.data,
|
|
257
|
+
columns: [
|
|
258
|
+
{ header: 'ID', get: (e) => e.id },
|
|
259
|
+
{ header: 'KIND', get: (e) => e.selectorKind },
|
|
260
|
+
{ header: 'STATUS', get: (e) => (e.status === 'running' ? `running (${e.phase})` : e.status) },
|
|
261
|
+
{ header: 'CREATED', get: (e) => e.createdAt },
|
|
262
|
+
{ header: 'COMPLETED', get: (e) => e.completedAt ?? '' },
|
|
263
|
+
{ header: 'REPLAYABLE', get: (e) => (e.matchable ? 'yes' : 'no') },
|
|
264
|
+
{ header: 'BY', get: (e) => e.requestedBy },
|
|
265
|
+
],
|
|
266
|
+
};
|
|
267
|
+
const SELECTOR_FLAGS = ['participant', 'external', 'fact', 'conversation'];
|
|
268
|
+
const erasuresCreate = {
|
|
269
|
+
kind: 'leaf',
|
|
270
|
+
name: 'create',
|
|
271
|
+
description: "Erase a person's words: their facts, conversations, the runs that served them, and what those left in provenance. Runs in the background; a tenant admin only.",
|
|
272
|
+
usage: 'kindgi memory erasures create (--participant=<id> | --external=<id> | --fact=<fact-id> | --conversation=<conversation-id>)',
|
|
273
|
+
optionSpec: {
|
|
274
|
+
participant: {
|
|
275
|
+
type: 'string',
|
|
276
|
+
description: "An app's end user (the `participantId` it gave).",
|
|
277
|
+
},
|
|
278
|
+
external: { type: 'string', description: 'A person facts name as an `external` subject.' },
|
|
279
|
+
fact: { type: 'string', description: 'One fact, every revision.' },
|
|
280
|
+
conversation: { type: 'string', description: 'One conversation.' },
|
|
281
|
+
},
|
|
282
|
+
run: (ctx) => runSdk(ctx, 'memory erasures create', async () => {
|
|
283
|
+
const given = SELECTOR_FLAGS.filter((f) => stringFlag(ctx, f) !== undefined);
|
|
284
|
+
if (given.length !== 1) {
|
|
285
|
+
throw new Error('Name exactly one of --participant, --external, --fact or --conversation');
|
|
286
|
+
}
|
|
287
|
+
const flag = given[0];
|
|
288
|
+
const id = stringFlag(ctx, flag);
|
|
289
|
+
return await ctx
|
|
290
|
+
.client()
|
|
291
|
+
.memory.erasures.create(flag === 'fact'
|
|
292
|
+
? { factId: id }
|
|
293
|
+
: flag === 'conversation'
|
|
294
|
+
? { conversationId: id }
|
|
295
|
+
: { subject: { kind: flag, id } });
|
|
296
|
+
}),
|
|
297
|
+
};
|
|
298
|
+
const erasuresGet = {
|
|
299
|
+
kind: 'leaf',
|
|
300
|
+
name: 'get',
|
|
301
|
+
description: 'An erasure: its status, phase, and what each store cleared.',
|
|
302
|
+
usage: 'kindgi memory erasures get <erasure-id>',
|
|
303
|
+
run: (ctx) => runSdk(ctx, 'memory erasures get', async () => ctx.client().memory.erasures.get(requiredPositional(ctx, 0, '<erasure-id>'))),
|
|
304
|
+
};
|
|
305
|
+
const erasuresList = {
|
|
306
|
+
kind: 'leaf',
|
|
307
|
+
name: 'list',
|
|
308
|
+
description: 'Erasures, newest first.',
|
|
309
|
+
usage: 'kindgi memory erasures list [--limit=<n>] [--cursor=<c>]',
|
|
310
|
+
optionSpec: {
|
|
311
|
+
limit: { type: 'string', description: 'The most to return (default 25, at most 100).' },
|
|
312
|
+
cursor: {
|
|
313
|
+
type: 'string',
|
|
314
|
+
description: "Resume after this cursor (the previous page's `nextCursor`).",
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
run: (ctx) => runSdk(ctx, 'memory erasures list', async () => {
|
|
318
|
+
const limit = integerFlag(ctx, 'limit');
|
|
319
|
+
const cursor = stringFlag(ctx, 'cursor');
|
|
320
|
+
return await ctx.client().memory.erasures.list({
|
|
321
|
+
...(limit !== undefined && { limit }),
|
|
322
|
+
...(cursor !== undefined && { cursor }),
|
|
323
|
+
});
|
|
324
|
+
}, ERASURES_TABLE),
|
|
325
|
+
};
|
|
326
|
+
const erasuresExport = {
|
|
327
|
+
kind: 'leaf',
|
|
328
|
+
name: 'export',
|
|
329
|
+
description: 'The erasure ledger, content-free, to keep off-box: restoring a backup rolls it back too, and `replay` takes it.',
|
|
330
|
+
usage: 'kindgi memory erasures export [--out=<file>]',
|
|
331
|
+
optionSpec: {
|
|
332
|
+
out: { type: 'string', description: 'Write it to this file (else, to stdout).' },
|
|
333
|
+
},
|
|
334
|
+
run: (ctx) => runSdk(ctx, 'memory erasures export', async () => {
|
|
335
|
+
const erasures = await ctx.client().memory.erasures.export();
|
|
336
|
+
const out = stringFlag(ctx, 'out');
|
|
337
|
+
if (out === undefined)
|
|
338
|
+
return { erasures };
|
|
339
|
+
await writeFile(out, `${JSON.stringify({ erasures }, null, 2)}\n`, 'utf8');
|
|
340
|
+
return { wrote: out, erasures: erasures.length };
|
|
341
|
+
}),
|
|
342
|
+
};
|
|
343
|
+
const erasuresReplay = {
|
|
344
|
+
kind: 'leaf',
|
|
345
|
+
name: 'replay',
|
|
346
|
+
description: 'After restoring a backup: put the exported ledger back, and erase again whoever the tenant holds again.',
|
|
347
|
+
usage: 'kindgi memory erasures replay <export-file>',
|
|
348
|
+
run: (ctx) => runSdk(ctx, 'memory erasures replay', async () => {
|
|
349
|
+
const file = requiredPositional(ctx, 0, '<export-file>');
|
|
350
|
+
const read = (await readJsonInput(`@${file}`));
|
|
351
|
+
const erasures = Array.isArray(read) ? read : (read.erasures ?? read.data);
|
|
352
|
+
if (!Array.isArray(erasures)) {
|
|
353
|
+
throw new Error(`${file} isn't an export: expected {"erasures": [...]}`);
|
|
354
|
+
}
|
|
355
|
+
return await ctx.client().memory.erasures.replay(erasures);
|
|
356
|
+
}),
|
|
357
|
+
};
|
|
358
|
+
const erasuresResume = {
|
|
359
|
+
kind: 'leaf',
|
|
360
|
+
name: 'resume',
|
|
361
|
+
description: 'Try an erasure again now; --force stops one waiting on a run in a flow that serves other people (that run is cancelled).',
|
|
362
|
+
usage: 'kindgi memory erasures resume <erasure-id> [--force]',
|
|
363
|
+
optionSpec: {
|
|
364
|
+
force: {
|
|
365
|
+
type: 'boolean',
|
|
366
|
+
description: "Don't wait for the shared flow's run: cancel it and go on (it would otherwise wait until its deadline).",
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
run: (ctx) => runSdk(ctx, 'memory erasures resume', async () => ctx.client().memory.erasures.resume(requiredPositional(ctx, 0, '<erasure-id>'), {
|
|
370
|
+
...(ctx.options.force === true && { force: true }),
|
|
371
|
+
})),
|
|
372
|
+
};
|
|
373
|
+
const erasuresGroup = {
|
|
374
|
+
kind: 'group',
|
|
375
|
+
name: 'erasures',
|
|
376
|
+
description: "Erasing a person's words: create, get, list, resume, export, replay (a tenant admin only).",
|
|
377
|
+
subcommands: [
|
|
378
|
+
erasuresCreate,
|
|
379
|
+
erasuresGet,
|
|
380
|
+
erasuresList,
|
|
381
|
+
erasuresResume,
|
|
382
|
+
erasuresExport,
|
|
383
|
+
erasuresReplay,
|
|
384
|
+
],
|
|
133
385
|
};
|
|
134
386
|
export const memoryCommand = {
|
|
135
387
|
kind: 'group',
|
|
136
388
|
name: 'memory',
|
|
137
|
-
description:
|
|
138
|
-
subcommands: [factsGroup],
|
|
389
|
+
description: "Memory: the facts agents remember, by type and scope, and erasing a person's words.",
|
|
390
|
+
subcommands: [factsGroup, erasuresGroup],
|
|
139
391
|
};
|
|
140
392
|
//# sourceMappingURL=memory.js.map
|