@w6w/cli 0.9.16 → 0.9.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 +3 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/src/args.d.ts +8 -1
- package/dist/src/args.d.ts.map +1 -1
- package/dist/src/args.js +15 -3
- package/dist/src/args.js.map +1 -1
- package/dist/src/commands/agents-studio.d.ts +24 -0
- package/dist/src/commands/agents-studio.d.ts.map +1 -0
- package/dist/src/commands/agents-studio.js +431 -0
- package/dist/src/commands/agents-studio.js.map +1 -0
- package/dist/src/commands/assets.d.ts +47 -0
- package/dist/src/commands/assets.d.ts.map +1 -0
- package/dist/src/commands/assets.js +412 -0
- package/dist/src/commands/assets.js.map +1 -0
- package/dist/src/commands/config.d.ts +21 -0
- package/dist/src/commands/config.d.ts.map +1 -0
- package/dist/src/commands/config.js +73 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.d.ts +1 -1
- package/dist/src/commands/connections.d.ts.map +1 -1
- package/dist/src/commands/connections.js +27 -2
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/index.d.ts +5 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +15 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/ls.d.ts +21 -0
- package/dist/src/commands/ls.d.ts.map +1 -0
- package/dist/src/commands/ls.js +53 -0
- package/dist/src/commands/ls.js.map +1 -0
- package/dist/src/commands/models.d.ts +16 -0
- package/dist/src/commands/models.d.ts.map +1 -0
- package/dist/src/commands/models.js +126 -0
- package/dist/src/commands/models.js.map +1 -0
- package/dist/src/commands/vars.d.ts.map +1 -1
- package/dist/src/commands/vars.js +2 -2
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/help.generated.d.ts.map +1 -1
- package/dist/src/help.generated.js +2549 -51
- package/dist/src/help.generated.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@ printf '%s' "$W6W_TOKEN" | w6w auth login - # preferred: keeps the token out o
|
|
|
31
31
|
w6w auth login <token> # also works, but the token lands in history and `ps`
|
|
32
32
|
w6w auth status # base URL, where it came from, masked token
|
|
33
33
|
w6w auth logout
|
|
34
|
+
w6w config get-base-url # effective base URL and its source
|
|
35
|
+
w6w config set-base-url https://w6w.example.com # save it (tokens are per host: auth login again)
|
|
34
36
|
```
|
|
35
37
|
|
|
36
38
|
The token is stored per user (`~/.config/w6w/config.json`, or `$XDG_CONFIG_HOME/w6w/…`;
|
|
@@ -60,6 +62,7 @@ server reachable, which is exactly when people need them most.
|
|
|
60
62
|
w6w me # who am I, and which CLI version is this? (alias: info)
|
|
61
63
|
|
|
62
64
|
# Discover what you can run — a `conn_…`, `wf_…`, `fn_…` or `ep_…` id.
|
|
65
|
+
w6w ls workflows # also: ls integrations | functions | endpoints (endpoints is unstable)
|
|
63
66
|
w6w connections list # short forms: `w6w conn ls`, `w6w wf ls`, `w6w docs ls`
|
|
64
67
|
w6w workflows list
|
|
65
68
|
w6w functions list
|
package/dist/mod.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export interface CommandContext {
|
|
|
86
86
|
readonly env: EnvReader;
|
|
87
87
|
/** The stored per-user config, read once before the handler runs (nothing stored by default). */
|
|
88
88
|
readonly stored: StoredConfig;
|
|
89
|
-
/** Where the config is persisted. Only the `auth` commands write through it. */
|
|
89
|
+
/** Where the config is persisted. Only the `auth` and `config` commands write through it. */
|
|
90
90
|
readonly store: ConfigStore;
|
|
91
91
|
/** Standard input, for `auth login -`. */
|
|
92
92
|
readonly stdin: StdinSource;
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAA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DAAwD;IACxD,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,gFAAgF;IAChF,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAwND;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAI/F;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CASxD"}
|
package/dist/mod.js
CHANGED
|
@@ -53,7 +53,7 @@ export { COMMAND_PATHS, EXIT_CODES, GLOBAL_FLAGS, HELP_TREE } from "./src/help.g
|
|
|
53
53
|
* The explicit `: string` annotation is required, not decorative: JSR publishes
|
|
54
54
|
* this file as TypeScript source and rejects inferred public types.
|
|
55
55
|
*/
|
|
56
|
-
export const VERSION = "0.9.
|
|
56
|
+
export const VERSION = "0.9.23";
|
|
57
57
|
/** `w6w help <command>` is accepted as an alias for `w6w <command> --help`. */
|
|
58
58
|
const HELP_COMMAND = "help";
|
|
59
59
|
/**
|
package/dist/src/args.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface Invocation {
|
|
|
50
50
|
globals: GlobalOptions;
|
|
51
51
|
/** Non-global flags, keyed by camelCased name. Empty unless `flags` was passed. */
|
|
52
52
|
options: Record<string, string | boolean>;
|
|
53
|
+
/** Every value of a repeatable flag (see {@linkcode REPEATABLE_FLAGS}), in order, by camelCased name. */
|
|
54
|
+
lists?: Record<string, string[]>;
|
|
53
55
|
}
|
|
54
56
|
/** What `parse()` returns: a parsed command line, or a usage error to report. */
|
|
55
57
|
export type ParseResult = {
|
|
@@ -67,6 +69,11 @@ export interface ParseOptions {
|
|
|
67
69
|
/** The command paths that exist. Defaults to the generated contract's. */
|
|
68
70
|
commands?: readonly (readonly string[])[];
|
|
69
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Flags that may be given more than once. Their values accumulate in
|
|
74
|
+
* `Invocation.lists`; `options` still holds the last one, as for every flag.
|
|
75
|
+
*/
|
|
76
|
+
export declare const REPEATABLE_FLAGS: ReadonlySet<string>;
|
|
70
77
|
/**
|
|
71
78
|
* Short spellings for a group name — pure typing convenience, not a second
|
|
72
79
|
* command. `w6w conn list` and `w6w connections list` resolve to the exact same
|
|
@@ -87,7 +94,7 @@ export declare const SUBCOMMAND_ALIASES: Record<string, string>;
|
|
|
87
94
|
*
|
|
88
95
|
* Accepted forms: `--flag`, `--flag value`, `--flag=value`, a short alias
|
|
89
96
|
* (`-h`, `-v`), and `--` to end flag parsing. A repeated flag keeps the last
|
|
90
|
-
* value. An unknown flag, a missing value, or a value handed to a boolean flag
|
|
97
|
+
* value (a repeatable one also accumulates all of them). An unknown flag, a missing value, or a value handed to a boolean flag
|
|
91
98
|
* are all reported as usage errors.
|
|
92
99
|
*/
|
|
93
100
|
export declare function parse(argv: string[], options?: ParseOptions): ParseResult;
|
package/dist/src/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,qCAAqC;AACrC,MAAM,WAAW,QAAQ;IACvB,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,EAAE,QAAQ,EAIrC,CAAC;AAEJ,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CA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MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC1C,yGAAyG;IACzG,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAClC;AAED,iFAAiF;AACjF,MAAM,MAAM,WAAW,GACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEtD,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;CAC3C;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAuB,CAAC;AAmCzE;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAErD,CAAC;AAuBF;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CAmF7E"}
|
package/dist/src/args.js
CHANGED
|
@@ -26,6 +26,11 @@ export const GLOBAL_FLAG_SPECS = GLOBAL_FLAGS.map((flag) => ({
|
|
|
26
26
|
alias: flag.alias,
|
|
27
27
|
type: flag.type,
|
|
28
28
|
}));
|
|
29
|
+
/**
|
|
30
|
+
* Flags that may be given more than once. Their values accumulate in
|
|
31
|
+
* `Invocation.lists`; `options` still holds the last one, as for every flag.
|
|
32
|
+
*/
|
|
33
|
+
export const REPEATABLE_FLAGS = new Set(["--stop"]);
|
|
29
34
|
/** `--base-url` → `baseUrl`. */
|
|
30
35
|
function optionKey(flagName) {
|
|
31
36
|
return flagName.replace(/^--/, "").replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
@@ -99,7 +104,7 @@ function normalizeAliases(operands) {
|
|
|
99
104
|
*
|
|
100
105
|
* Accepted forms: `--flag`, `--flag value`, `--flag=value`, a short alias
|
|
101
106
|
* (`-h`, `-v`), and `--` to end flag parsing. A repeated flag keeps the last
|
|
102
|
-
* value. An unknown flag, a missing value, or a value handed to a boolean flag
|
|
107
|
+
* value (a repeatable one also accumulates all of them). An unknown flag, a missing value, or a value handed to a boolean flag
|
|
103
108
|
* are all reported as usage errors.
|
|
104
109
|
*/
|
|
105
110
|
export function parse(argv, options = {}) {
|
|
@@ -108,6 +113,12 @@ export function parse(argv, options = {}) {
|
|
|
108
113
|
const byName = new Map(specs.map((spec) => [spec.name, spec]));
|
|
109
114
|
const byAlias = new Map(specs.filter((spec) => spec.alias).map((spec) => [spec.alias, spec]));
|
|
110
115
|
const values = {};
|
|
116
|
+
const lists = {};
|
|
117
|
+
const record = (name, value) => {
|
|
118
|
+
values[optionKey(name)] = value;
|
|
119
|
+
if (REPEATABLE_FLAGS.has(name))
|
|
120
|
+
(lists[optionKey(name)] ??= []).push(value);
|
|
121
|
+
};
|
|
111
122
|
const operands = [];
|
|
112
123
|
const fail = (message) => ({
|
|
113
124
|
ok: false,
|
|
@@ -137,14 +148,14 @@ export function parse(argv, options = {}) {
|
|
|
137
148
|
continue;
|
|
138
149
|
}
|
|
139
150
|
if (inlineValue !== null) {
|
|
140
|
-
|
|
151
|
+
record(spec.name, inlineValue);
|
|
141
152
|
continue;
|
|
142
153
|
}
|
|
143
154
|
const next = argv[i + 1];
|
|
144
155
|
if (next === undefined || (next.startsWith("-") && next !== "-")) {
|
|
145
156
|
return fail(`flag ${spec.name} requires a value`);
|
|
146
157
|
}
|
|
147
|
-
|
|
158
|
+
record(spec.name, next);
|
|
148
159
|
i++;
|
|
149
160
|
}
|
|
150
161
|
const { command, positionals } = splitCommand(normalizeAliases(operands), commands);
|
|
@@ -168,6 +179,7 @@ export function parse(argv, options = {}) {
|
|
|
168
179
|
help: values.help === true,
|
|
169
180
|
},
|
|
170
181
|
options: extras,
|
|
182
|
+
lists,
|
|
171
183
|
},
|
|
172
184
|
};
|
|
173
185
|
}
|
package/dist/src/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAY7E,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAe,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACvE,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,IAAI,EAAE,IAAI,CAAC,IAAI;CAChB,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAY7E,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAe,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACvE,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,IAAI,EAAE,IAAI,CAAC,IAAI;CAChB,CAAC,CAAC,CAAC;AAwCJ;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,Q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M,CAAC,IAAI,KAAK,IAAI;aAC3B;YACD,OAAO,EAAE,MAAM;YACf,KAAK;SACN;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w skills|context|agents …` — the agent-authoring surface at the command line.
|
|
3
|
+
*
|
|
4
|
+
* Seventeen commands, **one SDK call each**. Skill upload is deliberately not
|
|
5
|
+
* here: it is `w6w assets upload --purpose skill`.
|
|
6
|
+
*
|
|
7
|
+
* Two write paths carry optimistic concurrency — `agents update` and
|
|
8
|
+
* `context entries-update`. Both send the body `revision` and, when given, the
|
|
9
|
+
* `--if-unmodified-since` precondition. A `409` is re-thrown as an `ApiError`
|
|
10
|
+
* with a message naming the **current revision** and what to do next; a `428`
|
|
11
|
+
* says the precondition is required. Both keep their status, so the exit code is
|
|
12
|
+
* the API-error code and a script can tell the write was refused. A uniform
|
|
13
|
+
* `404` needs no handling at all: `main()` prints the server's one-line message
|
|
14
|
+
* and exits, never a stack trace.
|
|
15
|
+
*
|
|
16
|
+
* Only flags the user typed reach the wire, so an omitted `--description` leaves
|
|
17
|
+
* the field alone and `--description ""` clears it.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { CommandRegistry } from "../../mod.ts";
|
|
22
|
+
/** Keys are the help tree's command paths (`naming.cli`). */
|
|
23
|
+
export declare const AGENT_STUDIO_COMMANDS: CommandRegistry;
|
|
24
|
+
//# sourceMappingURL=agents-studio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-studio.d.ts","sourceRoot":"","sources":["../../../src/commands/agents-studio.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAkC,eAAe,EAAE,MAAM,cAAc,CAAC;AA+hBpF,6DAA6D;AAC7D,eAAO,MAAM,qBAAqB,EAAE,eAyBnC,CAAC"}
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w skills|context|agents …` — the agent-authoring surface at the command line.
|
|
3
|
+
*
|
|
4
|
+
* Seventeen commands, **one SDK call each**. Skill upload is deliberately not
|
|
5
|
+
* here: it is `w6w assets upload --purpose skill`.
|
|
6
|
+
*
|
|
7
|
+
* Two write paths carry optimistic concurrency — `agents update` and
|
|
8
|
+
* `context entries-update`. Both send the body `revision` and, when given, the
|
|
9
|
+
* `--if-unmodified-since` precondition. A `409` is re-thrown as an `ApiError`
|
|
10
|
+
* with a message naming the **current revision** and what to do next; a `428`
|
|
11
|
+
* says the precondition is required. Both keep their status, so the exit code is
|
|
12
|
+
* the API-error code and a script can tell the write was refused. A uniform
|
|
13
|
+
* `404` needs no handling at all: `main()` prints the server's one-line message
|
|
14
|
+
* and exits, never a stack trace.
|
|
15
|
+
*
|
|
16
|
+
* Only flags the user typed reach the wire, so an omitted `--description` leaves
|
|
17
|
+
* the field alone and `--description ""` clears it.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { ApiError } from "@w6w/sdk";
|
|
22
|
+
import { argument, noExtraArguments, requiredFlag, table, textFlag, usageError } from "./shared.js";
|
|
23
|
+
/** A positive-integer flag, or `undefined` when absent. */
|
|
24
|
+
function count(context, name) {
|
|
25
|
+
const value = textFlag(context, name);
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (!/^[0-9]+$/.test(value) || Number(value) < 1) {
|
|
29
|
+
throw usageError(context, `\`--${name}\` must be a positive integer.`);
|
|
30
|
+
}
|
|
31
|
+
return Number(value);
|
|
32
|
+
}
|
|
33
|
+
/** A non-negative integer flag that must be present (a revision may be `0`). */
|
|
34
|
+
function revision(context) {
|
|
35
|
+
const value = requiredFlag(context, "revision", "--revision <n>");
|
|
36
|
+
if (!/^[0-9]+$/.test(value)) {
|
|
37
|
+
throw usageError(context, "`--revision` must be a non-negative integer.");
|
|
38
|
+
}
|
|
39
|
+
return Number(value);
|
|
40
|
+
}
|
|
41
|
+
function includeArchived(context) {
|
|
42
|
+
return context.invocation.options.includeArchived === true ? { includeArchived: true } : {};
|
|
43
|
+
}
|
|
44
|
+
function tags(context) {
|
|
45
|
+
const value = textFlag(context, "tags");
|
|
46
|
+
if (value === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
return value.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
|
|
49
|
+
}
|
|
50
|
+
/** A flag whose value is a JSON array of pins. */
|
|
51
|
+
function jsonList(context, name) {
|
|
52
|
+
const value = textFlag(context, name);
|
|
53
|
+
if (value === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = JSON.parse(value);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw usageError(context, `\`--${name}\` must be valid JSON (an array).`);
|
|
61
|
+
}
|
|
62
|
+
if (!Array.isArray(parsed))
|
|
63
|
+
throw usageError(context, `\`--${name}\` must be a JSON array.`);
|
|
64
|
+
return parsed;
|
|
65
|
+
}
|
|
66
|
+
function visibility(context) {
|
|
67
|
+
const value = textFlag(context, "visibility");
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
if (value !== "private" && value !== "project" && value !== "account") {
|
|
71
|
+
throw usageError(context, "`--visibility` must be private, project or account.");
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
const cell = (value) => value === null || value === undefined || value === "" ? "-" : String(value);
|
|
76
|
+
/**
|
|
77
|
+
* Run a precondition write, turning a 409 / 428 into an actionable message.
|
|
78
|
+
*
|
|
79
|
+
* The thrown error is still an `ApiError` with the original status, code and
|
|
80
|
+
* body, so the exit code and `--json` consumers are unchanged; only the sentence
|
|
81
|
+
* a human reads is replaced.
|
|
82
|
+
*/
|
|
83
|
+
async function guarded(what, refetch, run) {
|
|
84
|
+
try {
|
|
85
|
+
return await run();
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
if (err instanceof ApiError && err.status === 409) {
|
|
89
|
+
const current = err.raw?.error
|
|
90
|
+
?.currentRevision;
|
|
91
|
+
const at = current === undefined ? "" : ` (current revision: ${current})`;
|
|
92
|
+
throw new ApiError(409, err.code, `Conflict: ${what} changed since you read it${at}. ` +
|
|
93
|
+
`Re-read it with \`${refetch}\` and retry with the new revision.`, err.raw);
|
|
94
|
+
}
|
|
95
|
+
if (err instanceof ApiError && err.status === 428) {
|
|
96
|
+
throw new ApiError(428, err.code, `Precondition required: ${what} can only be updated with a precondition. ` +
|
|
97
|
+
`Pass \`--if-unmodified-since <ts>\` (the updatedAt you read).`, err.raw);
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const precondition = (context) => ({
|
|
103
|
+
ifUnmodifiedSince: textFlag(context, "ifUnmodifiedSince"),
|
|
104
|
+
});
|
|
105
|
+
// ---------------------------------------------------------------- skills
|
|
106
|
+
const skillRow = (s) => [s.id, s.name, cell(s.activeVersionId), cell(s.archivedAt)];
|
|
107
|
+
const skillsList = async (context) => {
|
|
108
|
+
noExtraArguments(context, 0);
|
|
109
|
+
const rows = await context.client().skills.list({
|
|
110
|
+
...includeArchived(context),
|
|
111
|
+
limit: count(context, "limit"),
|
|
112
|
+
});
|
|
113
|
+
context.out.emit(rows, (styles) => rows.length === 0
|
|
114
|
+
? styles.dim("No skills.")
|
|
115
|
+
: table(["ID", "NAME", "ACTIVE VERSION", "ARCHIVED"], rows.map(skillRow), styles));
|
|
116
|
+
};
|
|
117
|
+
const skillsGet = async (context) => {
|
|
118
|
+
const id = argument(context, 0, "a skill id (see: `w6w skills list`)");
|
|
119
|
+
noExtraArguments(context, 1);
|
|
120
|
+
const skill = await context.client().skills.get(id);
|
|
121
|
+
context.out.emit(skill, (styles) => table(["ID", "NAME", "ACTIVE VERSION", "ARCHIVED"], [skillRow(skill)], styles));
|
|
122
|
+
};
|
|
123
|
+
const skillsVersions = async (context) => {
|
|
124
|
+
const id = argument(context, 0, "a skill id (see: `w6w skills list`)");
|
|
125
|
+
noExtraArguments(context, 1);
|
|
126
|
+
const rows = await context.client().skills.versions(id);
|
|
127
|
+
const row = (v) => {
|
|
128
|
+
const r = v;
|
|
129
|
+
return [cell(r.id), cell(r.version), cell(r.createdAt)];
|
|
130
|
+
};
|
|
131
|
+
context.out.emit(rows, (styles) => rows.length === 0
|
|
132
|
+
? styles.dim("No versions.")
|
|
133
|
+
: table(["ID", "VERSION", "CREATED"], rows.map(row), styles));
|
|
134
|
+
};
|
|
135
|
+
const skillsArchive = async (context) => {
|
|
136
|
+
const id = argument(context, 0, "a skill id (see: `w6w skills list`)");
|
|
137
|
+
noExtraArguments(context, 1);
|
|
138
|
+
const skill = await context.client().skills.archive(id);
|
|
139
|
+
context.out.emit(skill, (styles) => `Archived ${styles.bold(skill.name)} ${styles.dim(`(${id})`)}`);
|
|
140
|
+
};
|
|
141
|
+
// --------------------------------------------------------------- context
|
|
142
|
+
const collectionRow = (c) => [
|
|
143
|
+
c.id,
|
|
144
|
+
c.name,
|
|
145
|
+
c.tags.join(",") || "-",
|
|
146
|
+
c.visibility,
|
|
147
|
+
cell(c.archivedAt),
|
|
148
|
+
];
|
|
149
|
+
const COLLECTION_HEAD = ["ID", "NAME", "TAGS", "VISIBILITY", "ARCHIVED"];
|
|
150
|
+
const contextList = async (context) => {
|
|
151
|
+
noExtraArguments(context, 0);
|
|
152
|
+
const rows = await context.client().context.list({
|
|
153
|
+
...includeArchived(context),
|
|
154
|
+
limit: count(context, "limit"),
|
|
155
|
+
});
|
|
156
|
+
context.out.emit(rows, (styles) => rows.length === 0
|
|
157
|
+
? styles.dim("No context collections.")
|
|
158
|
+
: table(COLLECTION_HEAD, rows.map(collectionRow), styles));
|
|
159
|
+
};
|
|
160
|
+
const contextCreate = async (context) => {
|
|
161
|
+
const name = argument(context, 0, "a collection name");
|
|
162
|
+
noExtraArguments(context, 1);
|
|
163
|
+
const created = await context.client().context.create({
|
|
164
|
+
name,
|
|
165
|
+
description: textFlag(context, "description"),
|
|
166
|
+
tags: tags(context),
|
|
167
|
+
visibility: visibility(context),
|
|
168
|
+
});
|
|
169
|
+
context.out.emit(created, (styles) => `Created ${styles.bold(created.name)} ${styles.dim(`(${created.id})`)}`);
|
|
170
|
+
};
|
|
171
|
+
const contextGet = async (context) => {
|
|
172
|
+
const id = argument(context, 0, "a collection id (see: `w6w context list`)");
|
|
173
|
+
noExtraArguments(context, 1);
|
|
174
|
+
const found = await context.client().context.get(id);
|
|
175
|
+
context.out.emit(found, (styles) => table(COLLECTION_HEAD, [collectionRow(found)], styles));
|
|
176
|
+
};
|
|
177
|
+
/** A patch: only the typed flags are sent (collection edits are last-write-wins). */
|
|
178
|
+
const contextUpdate = async (context) => {
|
|
179
|
+
const id = argument(context, 0, "a collection id (see: `w6w context list`)");
|
|
180
|
+
noExtraArguments(context, 1);
|
|
181
|
+
const patch = {};
|
|
182
|
+
const name = textFlag(context, "name");
|
|
183
|
+
if (name !== undefined)
|
|
184
|
+
patch.name = name;
|
|
185
|
+
const description = textFlag(context, "description");
|
|
186
|
+
if (description !== undefined)
|
|
187
|
+
patch.description = description;
|
|
188
|
+
const tagList = tags(context);
|
|
189
|
+
if (tagList !== undefined)
|
|
190
|
+
patch.tags = tagList;
|
|
191
|
+
const updated = await context.client().context.update(id, patch);
|
|
192
|
+
context.out.emit(updated, (styles) => `Updated ${styles.bold(updated.name)} ${styles.dim(`(${id})`)}`);
|
|
193
|
+
};
|
|
194
|
+
const contextArchive = async (context) => {
|
|
195
|
+
const id = argument(context, 0, "a collection id (see: `w6w context list`)");
|
|
196
|
+
noExtraArguments(context, 1);
|
|
197
|
+
const archived = await context.client().context.archive(id);
|
|
198
|
+
context.out.emit(archived, (styles) => `Archived ${styles.bold(archived.name)} ${styles.dim(`(${id})`)}`);
|
|
199
|
+
};
|
|
200
|
+
const entryRow = (e) => [
|
|
201
|
+
e.id,
|
|
202
|
+
e.name,
|
|
203
|
+
e.mediaType,
|
|
204
|
+
cell(e.revision),
|
|
205
|
+
cell(e.archivedAt),
|
|
206
|
+
];
|
|
207
|
+
const ENTRY_HEAD = ["ID", "NAME", "TYPE", "REVISION", "ARCHIVED"];
|
|
208
|
+
const entriesList = async (context) => {
|
|
209
|
+
const id = argument(context, 0, "a collection id (see: `w6w context list`)");
|
|
210
|
+
noExtraArguments(context, 1);
|
|
211
|
+
const rows = await context.client().context.entries.list(id, includeArchived(context));
|
|
212
|
+
context.out.emit(rows, (styles) => rows.length === 0 ? styles.dim("No entries.") : table(ENTRY_HEAD, rows.map(entryRow), styles));
|
|
213
|
+
};
|
|
214
|
+
const entriesCreate = async (context) => {
|
|
215
|
+
const id = argument(context, 0, "a collection id (see: `w6w context list`)");
|
|
216
|
+
const name = argument(context, 1, "an entry name");
|
|
217
|
+
noExtraArguments(context, 2);
|
|
218
|
+
const entry = await context.client().context.entries.create(id, {
|
|
219
|
+
name,
|
|
220
|
+
text: requiredFlag(context, "text", "--text <text>"),
|
|
221
|
+
});
|
|
222
|
+
context.out.emit(entry, (styles) => `Created ${styles.bold(entry.name)} ${styles.dim(`(${entry.id}, revision ${entry.revision})`)}`);
|
|
223
|
+
};
|
|
224
|
+
const entriesUpdate = async (context) => {
|
|
225
|
+
const id = argument(context, 0, "a collection id (see: `w6w context list`)");
|
|
226
|
+
const entryId = argument(context, 1, "an entry id (see: `w6w context entries-list`)");
|
|
227
|
+
noExtraArguments(context, 2);
|
|
228
|
+
const text = requiredFlag(context, "text", "--text <text>");
|
|
229
|
+
const rev = revision(context);
|
|
230
|
+
const entry = await guarded("the entry", `w6w context entries-list ${id}`, () => context.client().context.entries.update(id, entryId, { text, revision: rev }, precondition(context)));
|
|
231
|
+
context.out.emit(entry, (styles) => `Updated ${styles.bold(entry.name)} ${styles.dim(`(${entry.id}, revision ${entry.revision})`)}`);
|
|
232
|
+
};
|
|
233
|
+
// ------------------------------------------------------- context-entries
|
|
234
|
+
const topEntryRow = (e) => [
|
|
235
|
+
e.id,
|
|
236
|
+
e.name,
|
|
237
|
+
cell(e.mediaType),
|
|
238
|
+
cell(e.revision),
|
|
239
|
+
];
|
|
240
|
+
const TOP_ENTRY_HEAD = ["ID", "NAME", "TYPE", "REVISION"];
|
|
241
|
+
const ceList = async (context) => {
|
|
242
|
+
noExtraArguments(context, 0);
|
|
243
|
+
const rows = await context.client().contextEntries.list({
|
|
244
|
+
...includeArchived(context),
|
|
245
|
+
collectionId: textFlag(context, "collectionId"),
|
|
246
|
+
project: textFlag(context, "project"),
|
|
247
|
+
});
|
|
248
|
+
context.out.emit(rows, (styles) => rows.length === 0
|
|
249
|
+
? styles.dim("No context entries.")
|
|
250
|
+
: table(TOP_ENTRY_HEAD, rows.map(topEntryRow), styles));
|
|
251
|
+
};
|
|
252
|
+
const ceCreate = async (context) => {
|
|
253
|
+
const name = argument(context, 0, "an entry name");
|
|
254
|
+
noExtraArguments(context, 1);
|
|
255
|
+
const ids = textFlag(context, "collectionId");
|
|
256
|
+
const collectionIds = ids === undefined
|
|
257
|
+
? undefined
|
|
258
|
+
: ids.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
259
|
+
const entry = await context.client().contextEntries.create({
|
|
260
|
+
name,
|
|
261
|
+
text: requiredFlag(context, "text", "--text <text>"),
|
|
262
|
+
visibility: visibility(context),
|
|
263
|
+
...(collectionIds ? { collectionIds } : {}),
|
|
264
|
+
});
|
|
265
|
+
context.out.emit(entry, (styles) => `Created ${styles.bold(entry.name)} ${styles.dim(`(${entry.id}, revision ${entry.revision})`)}`);
|
|
266
|
+
};
|
|
267
|
+
const ceGet = async (context) => {
|
|
268
|
+
const id = argument(context, 0, "an entry id (see: `w6w context-entries list`)");
|
|
269
|
+
noExtraArguments(context, 1);
|
|
270
|
+
const entry = await context.client().contextEntries.get(id);
|
|
271
|
+
context.out.emit(entry, (styles) => table(TOP_ENTRY_HEAD, [topEntryRow(entry)], styles));
|
|
272
|
+
};
|
|
273
|
+
const ceUpdate = async (context) => {
|
|
274
|
+
const id = argument(context, 0, "an entry id (see: `w6w context-entries list`)");
|
|
275
|
+
noExtraArguments(context, 1);
|
|
276
|
+
const text = requiredFlag(context, "text", "--text <text>");
|
|
277
|
+
const rev = revision(context);
|
|
278
|
+
const entry = await guarded("the entry", `w6w context-entries get ${id}`, () => context.client().contextEntries.update(id, { text, revision: rev }, precondition(context)));
|
|
279
|
+
context.out.emit(entry, (styles) => `Updated ${styles.bold(entry.name)} ${styles.dim(`(${entry.id}, revision ${entry.revision})`)}`);
|
|
280
|
+
};
|
|
281
|
+
const ceArchive = async (context) => {
|
|
282
|
+
const id = argument(context, 0, "an entry id (see: `w6w context-entries list`)");
|
|
283
|
+
noExtraArguments(context, 1);
|
|
284
|
+
const entry = await context.client().contextEntries.archive(id);
|
|
285
|
+
context.out.emit(entry, (styles) => `Archived ${styles.bold(entry.name)} ${styles.dim(`(${id})`)}`);
|
|
286
|
+
};
|
|
287
|
+
const ceAdd = async (context) => {
|
|
288
|
+
const id = argument(context, 0, "an entry id (see: `w6w context-entries list`)");
|
|
289
|
+
const collection = argument(context, 1, "a collection id (see: `w6w context list`)");
|
|
290
|
+
noExtraArguments(context, 2);
|
|
291
|
+
const entry = await context.client().contextEntries.addToCollection(id, collection);
|
|
292
|
+
context.out.emit(entry, (styles) => `Added ${styles.bold(entry.name)} to ${styles.dim(collection)}`);
|
|
293
|
+
};
|
|
294
|
+
const ceRemove = async (context) => {
|
|
295
|
+
const id = argument(context, 0, "an entry id (see: `w6w context-entries list`)");
|
|
296
|
+
const collection = argument(context, 1, "a collection id (see: `w6w context list`)");
|
|
297
|
+
noExtraArguments(context, 2);
|
|
298
|
+
const entry = await context.client().contextEntries.removeFromCollection(id, collection);
|
|
299
|
+
context.out.emit(entry, (styles) => `Removed ${styles.bold(entry.name)} from ${styles.dim(collection)}`);
|
|
300
|
+
};
|
|
301
|
+
// ---------------------------------------------------------------- agents
|
|
302
|
+
const agentRow = (a) => [
|
|
303
|
+
a.id,
|
|
304
|
+
cell(a.name),
|
|
305
|
+
cell(a.modelRouteId),
|
|
306
|
+
String(a.revision),
|
|
307
|
+
a.archived ? "yes" : "no",
|
|
308
|
+
"no",
|
|
309
|
+
];
|
|
310
|
+
const AGENT_HEAD = ["ID", "NAME", "MODEL ROUTE", "REVISION", "ARCHIVED", "RUNNABLE"];
|
|
311
|
+
const agentsList = async (context) => {
|
|
312
|
+
noExtraArguments(context, 0);
|
|
313
|
+
const rows = await context.client().agents.list(includeArchived(context));
|
|
314
|
+
context.out.emit(rows, (styles) => rows.length === 0 ? styles.dim("No agents.") : table(AGENT_HEAD, rows.map(agentRow), styles));
|
|
315
|
+
};
|
|
316
|
+
/** The fields `agents create|update` share, only those typed. */
|
|
317
|
+
function agentFields(context) {
|
|
318
|
+
const fields = {};
|
|
319
|
+
const name = textFlag(context, "name");
|
|
320
|
+
if (name !== undefined)
|
|
321
|
+
fields.name = name;
|
|
322
|
+
const instructions = textFlag(context, "instructions");
|
|
323
|
+
if (instructions !== undefined)
|
|
324
|
+
fields.instructions = instructions;
|
|
325
|
+
const route = textFlag(context, "modelRouteId");
|
|
326
|
+
if (route !== undefined)
|
|
327
|
+
fields.modelRouteId = route;
|
|
328
|
+
const skills = jsonList(context, "skills");
|
|
329
|
+
if (skills !== undefined)
|
|
330
|
+
fields.skills = skills;
|
|
331
|
+
const pins = jsonList(context, "context");
|
|
332
|
+
if (pins !== undefined)
|
|
333
|
+
fields.context = pins;
|
|
334
|
+
const vis = visibility(context);
|
|
335
|
+
if (vis !== undefined)
|
|
336
|
+
fields.visibility = vis;
|
|
337
|
+
const project = textFlag(context, "project");
|
|
338
|
+
if (project !== undefined)
|
|
339
|
+
fields.project = project;
|
|
340
|
+
const modelOptions = modelOptionFlags(context);
|
|
341
|
+
if (modelOptions !== undefined)
|
|
342
|
+
fields.modelOptions = modelOptions;
|
|
343
|
+
return fields;
|
|
344
|
+
}
|
|
345
|
+
/** `--temperature`, `--top-p`, `--max-output-tokens` and the repeatable `--stop`. */
|
|
346
|
+
function modelOptionFlags(context) {
|
|
347
|
+
const options = {};
|
|
348
|
+
const number = (name, min, max, integer) => {
|
|
349
|
+
const raw = textFlag(context, name);
|
|
350
|
+
if (raw === undefined)
|
|
351
|
+
return undefined;
|
|
352
|
+
const value = Number(raw);
|
|
353
|
+
if (raw.trim() === "" || !Number.isFinite(value) || value < min || value > max ||
|
|
354
|
+
(integer && !Number.isInteger(value))) {
|
|
355
|
+
throw usageError(context, `\`--${name}\` must be ${integer ? "an integer" : "a number"} from ${min} to ${max}.`);
|
|
356
|
+
}
|
|
357
|
+
return value;
|
|
358
|
+
};
|
|
359
|
+
const temperature = number("temperature", 0, 2, false);
|
|
360
|
+
if (temperature !== undefined)
|
|
361
|
+
options.temperature = temperature;
|
|
362
|
+
const topP = number("topP", 0, 1, false);
|
|
363
|
+
if (topP !== undefined)
|
|
364
|
+
options.topP = topP;
|
|
365
|
+
const max = number("maxOutputTokens", 1, 1_000_000, true);
|
|
366
|
+
if (max !== undefined)
|
|
367
|
+
options.maxOutputTokens = max;
|
|
368
|
+
const stop = context.invocation.lists?.stop;
|
|
369
|
+
if (stop !== undefined)
|
|
370
|
+
options.stop = stop;
|
|
371
|
+
return Object.keys(options).length > 0 ? options : undefined;
|
|
372
|
+
}
|
|
373
|
+
const agentsCreate = async (context) => {
|
|
374
|
+
noExtraArguments(context, 0);
|
|
375
|
+
const agent = await context.client().agents.create(agentFields(context));
|
|
376
|
+
context.out.emit(agent, (styles) => `Created ${styles.bold(cell(agent.name))} ${styles.dim(`(${agent.id}, revision ${agent.revision})`)}`);
|
|
377
|
+
};
|
|
378
|
+
const agentsGet = async (context) => {
|
|
379
|
+
const id = argument(context, 0, "an agent id (see: `w6w agents list`)");
|
|
380
|
+
noExtraArguments(context, 1);
|
|
381
|
+
const agent = await context.client().agents.get(id);
|
|
382
|
+
context.out.emit(agent, (styles) => {
|
|
383
|
+
const issues = agent.validation.map((v) => ` ! ${JSON.stringify(v)}`);
|
|
384
|
+
return [
|
|
385
|
+
table(AGENT_HEAD, [agentRow(agent)], styles),
|
|
386
|
+
...(agent.instructions.length > 0 ? ["", agent.instructions] : []),
|
|
387
|
+
...(issues.length > 0 ? ["", "Validation:", ...issues] : []),
|
|
388
|
+
].join("\n");
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
const agentsUpdate = async (context) => {
|
|
392
|
+
const id = argument(context, 0, "an agent id (see: `w6w agents list`)");
|
|
393
|
+
noExtraArguments(context, 1);
|
|
394
|
+
const patch = { ...agentFields(context), revision: revision(context) };
|
|
395
|
+
const agent = await guarded("the agent", `w6w agents get ${id}`, () => context.client().agents.update(id, patch, precondition(context)));
|
|
396
|
+
context.out.emit(agent, (styles) => `Updated ${styles.bold(cell(agent.name))} ${styles.dim(`(${id}, revision ${agent.revision})`)}`);
|
|
397
|
+
};
|
|
398
|
+
const agentsArchive = async (context) => {
|
|
399
|
+
const id = argument(context, 0, "an agent id (see: `w6w agents list`)");
|
|
400
|
+
noExtraArguments(context, 1);
|
|
401
|
+
const agent = await context.client().agents.archive(id);
|
|
402
|
+
context.out.emit(agent, (styles) => `Archived ${styles.bold(cell(agent.name))} ${styles.dim(`(${id})`)}`);
|
|
403
|
+
};
|
|
404
|
+
/** Keys are the help tree's command paths (`naming.cli`). */
|
|
405
|
+
export const AGENT_STUDIO_COMMANDS = {
|
|
406
|
+
"skills list": skillsList,
|
|
407
|
+
"skills get": skillsGet,
|
|
408
|
+
"skills versions": skillsVersions,
|
|
409
|
+
"skills archive": skillsArchive,
|
|
410
|
+
"context list": contextList,
|
|
411
|
+
"context create": contextCreate,
|
|
412
|
+
"context get": contextGet,
|
|
413
|
+
"context update": contextUpdate,
|
|
414
|
+
"context archive": contextArchive,
|
|
415
|
+
"context entries-list": entriesList,
|
|
416
|
+
"context entries-create": entriesCreate,
|
|
417
|
+
"context entries-update": entriesUpdate,
|
|
418
|
+
"context-entries list": ceList,
|
|
419
|
+
"context-entries create": ceCreate,
|
|
420
|
+
"context-entries get": ceGet,
|
|
421
|
+
"context-entries update": ceUpdate,
|
|
422
|
+
"context-entries archive": ceArchive,
|
|
423
|
+
"context-entries add-to-collection": ceAdd,
|
|
424
|
+
"context-entries remove-from-collection": ceRemove,
|
|
425
|
+
"agents list": agentsList,
|
|
426
|
+
"agents create": agentsCreate,
|
|
427
|
+
"agents get": agentsGet,
|
|
428
|
+
"agents update": agentsUpdate,
|
|
429
|
+
"agents archive": agentsArchive,
|
|
430
|
+
};
|
|
431
|
+
//# sourceMappingURL=agents-studio.js.map
|