@revition/plugin-agents 0.0.0-canary.a06d97b
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/LICENSE +201 -0
- package/NOTICE +8 -0
- package/dist/commands/agents/create.d.ts +26 -0
- package/dist/commands/agents/create.js +46 -0
- package/dist/commands/agents/create.js.map +1 -0
- package/dist/commands/agents/diff.d.ts +22 -0
- package/dist/commands/agents/diff.js +41 -0
- package/dist/commands/agents/diff.js.map +1 -0
- package/dist/commands/agents/environments/list.d.ts +37 -0
- package/dist/commands/agents/environments/list.js +39 -0
- package/dist/commands/agents/environments/list.js.map +1 -0
- package/dist/commands/agents/list.d.ts +44 -0
- package/dist/commands/agents/list.js +75 -0
- package/dist/commands/agents/list.js.map +1 -0
- package/dist/commands/agents/open.d.ts +31 -0
- package/dist/commands/agents/open.js +47 -0
- package/dist/commands/agents/open.js.map +1 -0
- package/dist/commands/agents/pull.d.ts +29 -0
- package/dist/commands/agents/pull.js +69 -0
- package/dist/commands/agents/pull.js.map +1 -0
- package/dist/commands/agents/push.d.ts +31 -0
- package/dist/commands/agents/push.js +63 -0
- package/dist/commands/agents/push.js.map +1 -0
- package/dist/commands/agents/runs.d.ts +47 -0
- package/dist/commands/agents/runs.js +70 -0
- package/dist/commands/agents/runs.js.map +1 -0
- package/dist/commands/agents/status.d.ts +29 -0
- package/dist/commands/agents/status.js +47 -0
- package/dist/commands/agents/status.js.map +1 -0
- package/dist/commands/agents/templates.d.ts +20 -0
- package/dist/commands/agents/templates.js +26 -0
- package/dist/commands/agents/templates.js.map +1 -0
- package/dist/commands/agents/test.d.ts +58 -0
- package/dist/commands/agents/test.js +73 -0
- package/dist/commands/agents/test.js.map +1 -0
- package/dist/commands/agents/traces.d.ts +46 -0
- package/dist/commands/agents/traces.js +80 -0
- package/dist/commands/agents/traces.js.map +1 -0
- package/dist/commands/agents/validate.d.ts +43 -0
- package/dist/commands/agents/validate.js +76 -0
- package/dist/commands/agents/validate.js.map +1 -0
- package/dist/format.d.ts +49 -0
- package/dist/format.js +48 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/agent-definition.v1.json +233 -0
- package/dist/validate.d.ts +21 -0
- package/dist/validate.js +55 -0
- package/dist/validate.js.map +1 -0
- package/oclif.manifest.json +1463 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Revition
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Revition CLI
|
|
2
|
+
Copyright 2026 Revition
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Trademarks: "Revition", the Revition name and the Revition logo are trademarks of Revition. The Apache License does not
|
|
7
|
+
grant permission to use them, except as required for reasonable and customary use in describing the origin of the work
|
|
8
|
+
and reproducing the content of this NOTICE file (Apache License 2.0, section 6).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RevitionCommand, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
interface Out {
|
|
3
|
+
readonly agentId: string;
|
|
4
|
+
readonly template: string;
|
|
5
|
+
readonly version: number;
|
|
6
|
+
readonly file: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* T3.1.3 - `revition agents create <file> [--template <id>]`: a new agent the way the web makes one (POST
|
|
10
|
+
* /agent-templates/scaffold, `blank` by default), then the file's body saved to its DRAFT. The live agent is
|
|
11
|
+
* untouched; the file gets the new id so later pushes go to it.
|
|
12
|
+
*/
|
|
13
|
+
export default class AgentsCreate extends RevitionCommand<Out> {
|
|
14
|
+
static summary: string;
|
|
15
|
+
static examples: string[];
|
|
16
|
+
static meta: CommandMeta;
|
|
17
|
+
static args: {
|
|
18
|
+
file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
19
|
+
};
|
|
20
|
+
static flags: {
|
|
21
|
+
template: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
};
|
|
23
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
24
|
+
protected human(o: Out): HumanView;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { atomicWriteFile, RevitionCommand, usageError } from '@revition/cli-core';
|
|
4
|
+
import { definitionText, draftBody } from '../../format.js';
|
|
5
|
+
import { agentsApi, bodyHash, projectDir, readDefinition, seg, writePullRecord } from './list.js';
|
|
6
|
+
/**
|
|
7
|
+
* T3.1.3 - `revition agents create <file> [--template <id>]`: a new agent the way the web makes one (POST
|
|
8
|
+
* /agent-templates/scaffold, `blank` by default), then the file's body saved to its DRAFT. The live agent is
|
|
9
|
+
* untouched; the file gets the new id so later pushes go to it.
|
|
10
|
+
*/
|
|
11
|
+
export default class AgentsCreate extends RevitionCommand {
|
|
12
|
+
static summary = 'Create an agent from a definition file (its draft = the file; nothing goes live).';
|
|
13
|
+
static examples = ['revition agents create agents/support.agent.yaml', 'revition agents create agents/support.agent.yaml --template blank --yes'];
|
|
14
|
+
static meta = {
|
|
15
|
+
id: 'agents:create',
|
|
16
|
+
summary: AgentsCreate.summary,
|
|
17
|
+
examples: AgentsCreate.examples,
|
|
18
|
+
requiredScopes: ['cli:agents'],
|
|
19
|
+
mutates: true,
|
|
20
|
+
confirm: 'prompt',
|
|
21
|
+
jsonSchemaId: 'revition.agents.create.v1',
|
|
22
|
+
stability: 'beta',
|
|
23
|
+
};
|
|
24
|
+
static args = { file: Args.string({ required: true, description: 'The definition file (agent.id: null).' }) };
|
|
25
|
+
static flags = { template: Flags.string({ description: 'The template to start from (default: blank; see `revition agents templates`).' }) };
|
|
26
|
+
async run2(ctx) {
|
|
27
|
+
const dir = projectDir();
|
|
28
|
+
const file = resolve(dir, String(ctx.args['file']));
|
|
29
|
+
const { definition } = readDefinition(file);
|
|
30
|
+
if (definition.agent.id !== null) {
|
|
31
|
+
throw usageError('AGENT_EXISTS', `This file already names agent ${definition.agent.id}.`, 'Use `revition agents push` to change its draft.');
|
|
32
|
+
}
|
|
33
|
+
const template = typeof ctx.commandFlags['template'] === 'string' ? ctx.commandFlags['template'] : 'blank';
|
|
34
|
+
const api = await agentsApi(ctx);
|
|
35
|
+
const made = (await api.request({ method: 'POST', path: '/agent-templates/scaffold', body: { templateAppId: template, name: definition.agent.name } })).body;
|
|
36
|
+
const saved = (await api.request({ method: 'PUT', path: `/deployments/${seg(made.deploymentId)}/draft`, body: draftBody(definition, null) })).body;
|
|
37
|
+
const withId = { ...definition, agent: { ...definition.agent, id: made.deploymentId } };
|
|
38
|
+
await atomicWriteFile(file, definitionText(withId));
|
|
39
|
+
await writePullRecord(dir, { agentId: made.deploymentId, version: saved.draft.version, bodyHash: bodyHash(definition.config) });
|
|
40
|
+
return { agentId: made.deploymentId, template, version: saved.draft.version, file };
|
|
41
|
+
}
|
|
42
|
+
human(o) {
|
|
43
|
+
return { text: `Created ${o.agentId} from ${o.template}; its draft (version ${o.version}) is the file, now pointing at it: ${o.file}\nGo live in the portal: revition agents open ${o.agentId} --action publish\n` };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/agents/create.ts"],"names":[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AAM,CAAC,CAAC,CAAC;QACpD,MAAM,eAAe,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChI,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACtF,CAAC;IAEkB,KAAK,CAAC,CAAM;QAC7B,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,QAAQ,wBAAwB,CAAC,CAAC,OAAO,sCAAsC,CAAC,CAAC,IAAI,iDAAiD,CAAC,CAAC,OAAO,qBAAqB,EAAE,CAAC;IACvN,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RevitionCommand, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
import { type SectionDiff } from '../../format.js';
|
|
3
|
+
import type { DraftDiff } from './push.js';
|
|
4
|
+
interface Out {
|
|
5
|
+
readonly agentId: string;
|
|
6
|
+
/** The file against the remote draft, by section (config fields and sections). */
|
|
7
|
+
readonly vsDraft: SectionDiff;
|
|
8
|
+
/** The remote draft against the live agent (the platform's own diff). */
|
|
9
|
+
readonly draftVsLive: DraftDiff;
|
|
10
|
+
}
|
|
11
|
+
/** T3.1.3 - `revition agents diff <file>`: what the file would change in the draft, and the draft against live. */
|
|
12
|
+
export default class AgentsDiff extends RevitionCommand<Out> {
|
|
13
|
+
static summary: string;
|
|
14
|
+
static examples: string[];
|
|
15
|
+
static meta: CommandMeta;
|
|
16
|
+
static args: {
|
|
17
|
+
file: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
18
|
+
};
|
|
19
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
20
|
+
protected human(o: Out): HumanView;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { Args } from '@oclif/core';
|
|
3
|
+
import { RevitionCommand, usageError } from '@revition/cli-core';
|
|
4
|
+
import { diffBySection, isEmptyDiff } from '../../format.js';
|
|
5
|
+
import { agentsApi, getDraft, projectDir, readDefinition, seg } from './list.js';
|
|
6
|
+
/** T3.1.3 - `revition agents diff <file>`: what the file would change in the draft, and the draft against live. */
|
|
7
|
+
export default class AgentsDiff extends RevitionCommand {
|
|
8
|
+
static summary = 'Show what a definition file changes in the draft (by section), and the draft against live.';
|
|
9
|
+
static examples = ['revition agents diff agents/support.agent.yaml', 'revition agents diff agents/support.agent.yaml --json'];
|
|
10
|
+
static meta = {
|
|
11
|
+
id: 'agents:diff',
|
|
12
|
+
summary: AgentsDiff.summary,
|
|
13
|
+
examples: AgentsDiff.examples,
|
|
14
|
+
requiredScopes: ['cli:agents'],
|
|
15
|
+
mutates: false,
|
|
16
|
+
confirm: 'none',
|
|
17
|
+
jsonSchemaId: 'revition.agents.diff.v1',
|
|
18
|
+
stability: 'beta',
|
|
19
|
+
};
|
|
20
|
+
static args = { file: Args.string({ required: true, description: 'The definition file.' }) };
|
|
21
|
+
async run2(ctx) {
|
|
22
|
+
const { definition } = readDefinition(resolve(projectDir(), String(ctx.args['file'])));
|
|
23
|
+
const id = definition.agent.id;
|
|
24
|
+
if (id === null)
|
|
25
|
+
throw usageError('NO_AGENT_ID', 'This file names no agent yet (agent.id is null).', 'Create the agent with `revition agents create <file>`.');
|
|
26
|
+
const api = await agentsApi(ctx);
|
|
27
|
+
const draft = await getDraft(api, id);
|
|
28
|
+
const vsDraft = diffBySection({ config: draft.config, sections: draft.sections }, definition.config);
|
|
29
|
+
const draftVsLive = (await api.request({ method: 'GET', path: `/deployments/${seg(id)}/draft/diff` })).body;
|
|
30
|
+
return { agentId: id, vsDraft, draftVsLive };
|
|
31
|
+
}
|
|
32
|
+
human(o) {
|
|
33
|
+
const d = o.vsDraft;
|
|
34
|
+
const local = isEmptyDiff(d)
|
|
35
|
+
? ['File vs draft: no changes.']
|
|
36
|
+
: ['File vs draft:', ...d.added.map((s) => ` + ${s}`), ...d.removed.map((s) => ` - ${s}`), ...d.changed.map((s) => ` ~ ${s}`)];
|
|
37
|
+
const live = o.draftVsLive;
|
|
38
|
+
return { text: `${[...local, `Draft vs live: ${live.changedSections.join(', ') || 'no difference'}`].join('\n')}\n` };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/commands/agents/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAyD,MAAM,oBAAoB,CAAC;AAExH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAoB,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAWjF,mHAAmH;AACnH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,eAAoB;IAC1D,MAAM,CAAU,OAAO,GAAG,4FAA4F,CAAC;IACvH,MAAM,CAAU,QAAQ,GAAG,CAAC,gDAAgD,EAAE,uDAAuD,CAAC,CAAC;IACvI,MAAM,CAAC,IAAI,GAAgB;QACzB,EAAE,EAAE,aAAa;QACjB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,cAAc,EAAE,CAAC,YAAY,CAAC;QAC9B,OAAO,EAAE,KAAK;QACd,OAAO,EA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AC,CAAC;YAC1B,CAAC,CAAC,CAAC,4BAA4B,CAAC;YAChC,CAAC,CAAC,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QACpI,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE,kBAAkB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACxH,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RevitionCommand, type ApiClient, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
/** One environment as GET /deployments/{id}/environments lists it (foundry runtime/environments EnvState + pending). */
|
|
3
|
+
export interface EnvView {
|
|
4
|
+
readonly env: string;
|
|
5
|
+
readonly provisioned: boolean;
|
|
6
|
+
readonly artifactRef: string | null;
|
|
7
|
+
readonly promotedAt?: string;
|
|
8
|
+
readonly approvedBy?: string;
|
|
9
|
+
readonly pending: {
|
|
10
|
+
readonly from: string;
|
|
11
|
+
readonly to: string;
|
|
12
|
+
readonly requestedBy: string;
|
|
13
|
+
readonly requestedAt: string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
export interface Environments {
|
|
17
|
+
readonly managed: unknown;
|
|
18
|
+
readonly environments: readonly EnvView[];
|
|
19
|
+
}
|
|
20
|
+
export declare function environmentsOf(api: ApiClient, id: string): Promise<Environments>;
|
|
21
|
+
/** Each environment as a line, the pending approval included. PURE. */
|
|
22
|
+
export declare function envLines(envs: readonly EnvView[]): string[];
|
|
23
|
+
interface Out extends Environments {
|
|
24
|
+
readonly agentId: string;
|
|
25
|
+
}
|
|
26
|
+
/** T3.1.4 - `revition agents environments list <id>`; promotion and approval are human steps in the portal (D9). */
|
|
27
|
+
export default class AgentsEnvironmentsList extends RevitionCommand<Out> {
|
|
28
|
+
static summary: string;
|
|
29
|
+
static examples: string[];
|
|
30
|
+
static meta: CommandMeta;
|
|
31
|
+
static args: {
|
|
32
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
33
|
+
};
|
|
34
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
35
|
+
protected human(o: Out): HumanView;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { RevitionCommand, renderTable, terminalTable } from '@revition/cli-core';
|
|
3
|
+
import { agentsApi, seg } from '../list.js';
|
|
4
|
+
export async function environmentsOf(api, id) {
|
|
5
|
+
return (await api.request({ method: 'GET', path: `/deployments/${seg(id)}/environments` })).body;
|
|
6
|
+
}
|
|
7
|
+
/** Each environment as a line, the pending approval included. PURE. */
|
|
8
|
+
export function envLines(envs) {
|
|
9
|
+
return envs.map((e) => `${e.env}: ${e.provisioned ? (e.artifactRef ?? 'provisioned, empty') : 'not enabled'}${e.pending === null ? '' : ` - approval pending (${e.pending.from} -> ${e.pending.to}, requested by ${e.pending.requestedBy})`}`);
|
|
10
|
+
}
|
|
11
|
+
/** T3.1.4 - `revition agents environments list <id>`; promotion and approval are human steps in the portal (D9). */
|
|
12
|
+
export default class AgentsEnvironmentsList extends RevitionCommand {
|
|
13
|
+
static summary = "An agent's environments, what each runs, and any promotion waiting for approval.";
|
|
14
|
+
static examples = ['revition agents environments list dep_123', 'revition agents environments list dep_123 --json'];
|
|
15
|
+
static meta = {
|
|
16
|
+
id: 'agents:environments:list',
|
|
17
|
+
summary: AgentsEnvironmentsList.summary,
|
|
18
|
+
examples: AgentsEnvironmentsList.examples,
|
|
19
|
+
requiredScopes: ['cli:agents'],
|
|
20
|
+
mutates: false,
|
|
21
|
+
confirm: 'none',
|
|
22
|
+
jsonSchemaId: 'revition.agents.environments.list.v1',
|
|
23
|
+
stability: 'beta',
|
|
24
|
+
};
|
|
25
|
+
static args = { id: Args.string({ required: true, description: 'The agent (deployment id).' }) };
|
|
26
|
+
async run2(ctx) {
|
|
27
|
+
const id = String(ctx.args['id']);
|
|
28
|
+
return { agentId: id, ...(await environmentsOf(await agentsApi(ctx), id)) };
|
|
29
|
+
}
|
|
30
|
+
human(o) {
|
|
31
|
+
if (!o.environments.some((e) => e.provisioned)) {
|
|
32
|
+
return { text: `Environments are not enabled for ${o.agentId}: an Owner or Admin enables them in the portal (revition agents open ${o.agentId} --action promote).\n` };
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
text: renderTable(['env', 'runs', 'pending approval'], o.environments.map((e) => [e.env, e.provisioned ? (e.artifactRef ?? '-') : 'not enabled', e.pending === null ? '-' : `${e.pending.from} -> ${e.pending.to}`]), terminalTable()),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/agents/environments/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAyE,MAAM,oBAAoB,CAAC;AAExJ,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAiB5C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAc,EAAE,EAAU;IAC7D,OAAO,CAAC,M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AAE,CAAC,EAAE,CAAC;IAEhG,KAAK,CAAC,IAAI,CAAC,GAAmB;QACtC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAClC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,MAAM,cAAc,CAAC,MAAM,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;IAC9E,CAAC;IAEkB,KAAK,CAAC,CAAM;QAC7B,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/C,OAAO,EAAE,IAAI,EAAE,oCAAoC,CAAC,CAAC,OAAO,wEAAwE,CAAC,CAAC,OAAO,uBAAuB,EAAE,CAAC;QACzK,CAAC;QACD,OAAO;YACL,IAAI,EAAE,WAAW,CACf,CAAC,KAAK,EAAE,MAAM,EAAE,kBAAkB,CAAC,EACnC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAC7J,aAAa,EAAE,CAChB;SACF,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RevitionCommand, type ApiClient, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
import { type AgentDefinition, type DraftView } from '../../format.js';
|
|
3
|
+
import { type Finding } from '../../validate.js';
|
|
4
|
+
/**
|
|
5
|
+
* T3.1.3 - the agents commands' shared plumbing: the signed-in client (a workspace API: an independent developer is
|
|
6
|
+
* refused by the platform), a definition file read and checked locally, and the pull record that lets `push` send
|
|
7
|
+
* the version it read (`baseVersion`, T3.1.2) and lets `pull` see local edits.
|
|
8
|
+
*/
|
|
9
|
+
export declare function agentsApi(ctx: CommandContext): Promise<ApiClient>;
|
|
10
|
+
export declare const seg: (s: string) => string;
|
|
11
|
+
export interface Deployment {
|
|
12
|
+
readonly deploymentId: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly status?: string;
|
|
15
|
+
readonly role?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function getDraft(api: ApiClient, id: string): Promise<DraftView>;
|
|
18
|
+
/** A definition file, read and checked locally (schema + secret scan); refused with every finding when it fails. */
|
|
19
|
+
export declare function readDefinition(file: string): {
|
|
20
|
+
readonly definition: AgentDefinition;
|
|
21
|
+
readonly warnings: readonly Finding[];
|
|
22
|
+
};
|
|
23
|
+
/** The pull record: `.revition/agents/<id>.json` (the draft version read and a hash of the body; no content). */
|
|
24
|
+
export interface PullRecord {
|
|
25
|
+
readonly agentId: string;
|
|
26
|
+
readonly version: number;
|
|
27
|
+
readonly bodyHash: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const bodyHash: (body: AgentDefinition["config"]) => string;
|
|
30
|
+
export declare const pullRecordFile: (dir: string, agentId: string) => string;
|
|
31
|
+
export declare function readPullRecord(dir: string, agentId: string): PullRecord | null;
|
|
32
|
+
export declare function writePullRecord(dir: string, r: PullRecord): Promise<void>;
|
|
33
|
+
export declare const projectDir: () => string;
|
|
34
|
+
interface Out {
|
|
35
|
+
readonly agents: readonly Deployment[];
|
|
36
|
+
}
|
|
37
|
+
export default class AgentsList extends RevitionCommand<Out> {
|
|
38
|
+
static summary: string;
|
|
39
|
+
static examples: string[];
|
|
40
|
+
static meta: CommandMeta;
|
|
41
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
42
|
+
protected human(o: Out): HumanView;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { atomicWriteFile, EXIT, RevitionCliError, RevitionCommand, renderTable, runtime, terminalTable, usageError, } from '@revition/cli-core';
|
|
5
|
+
import { canonical } from '../../format.js';
|
|
6
|
+
import { validateLocal } from '../../validate.js';
|
|
7
|
+
/**
|
|
8
|
+
* T3.1.3 - the agents commands' shared plumbing: the signed-in client (a workspace API: an independent developer is
|
|
9
|
+
* refused by the platform), a definition file read and checked locally, and the pull record that lets `push` send
|
|
10
|
+
* the version it read (`baseVersion`, T3.1.2) and lets `pull` see local edits.
|
|
11
|
+
*/
|
|
12
|
+
export async function agentsApi(ctx) {
|
|
13
|
+
const rt = await runtime(ctx);
|
|
14
|
+
if (rt.session.mode === 'none')
|
|
15
|
+
throw new RevitionCliError({ code: 'AUTH_REQUIRED', message: 'You are not signed in.', hint: 'Run `revition login`.' }, EXIT.auth);
|
|
16
|
+
return rt.session.client;
|
|
17
|
+
}
|
|
18
|
+
export const seg = (s) => encodeURIComponent(s);
|
|
19
|
+
export async function getDraft(api, id) {
|
|
20
|
+
return (await api.request({ method: 'GET', path: `/deployments/${seg(id)}/draft` })).body.draft;
|
|
21
|
+
}
|
|
22
|
+
/** A definition file, read and checked locally (schema + secret scan); refused with every finding when it fails. */
|
|
23
|
+
export function readDefinition(file) {
|
|
24
|
+
if (!existsSync(file))
|
|
25
|
+
throw usageError('FILE_NOT_FOUND', `No such file: ${file}.`);
|
|
26
|
+
const r = validateLocal(readFileSync(file, 'utf8'));
|
|
27
|
+
if (!r.ok || r.definition === null) {
|
|
28
|
+
const lines = r.problems.map((p) => `${p.line === null ? p.path : `line ${p.line}`}: ${p.message}`);
|
|
29
|
+
throw new RevitionCliError({ code: 'DEFINITION_INVALID', message: `${file} is not a valid agent definition:\n ${lines.join('\n ')}`, hint: 'Run `revition agents validate` for the details.' }, EXIT.conflict);
|
|
30
|
+
}
|
|
31
|
+
return { definition: r.definition, warnings: r.warnings };
|
|
32
|
+
}
|
|
33
|
+
export const bodyHash = (body) => createHash('sha256').update(canonical(body)).digest('hex');
|
|
34
|
+
export const pullRecordFile = (dir, agentId) => join(dir, '.revition', 'agents', `${agentId.replace(/[^A-Za-z0-9_-]/g, '_')}.json`);
|
|
35
|
+
export function readPullRecord(dir, agentId) {
|
|
36
|
+
const f = pullRecordFile(dir, agentId);
|
|
37
|
+
if (!existsSync(f))
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function writePullRecord(dir, r) {
|
|
47
|
+
await atomicWriteFile(pullRecordFile(dir, r.agentId), `${JSON.stringify(r, null, 2)}\n`);
|
|
48
|
+
}
|
|
49
|
+
export const projectDir = () => resolve(process.cwd());
|
|
50
|
+
export default class AgentsList extends RevitionCommand {
|
|
51
|
+
static summary = "Your workspace's agents.";
|
|
52
|
+
static examples = ['revition agents list', 'revition agents list --json'];
|
|
53
|
+
static meta = {
|
|
54
|
+
id: 'agents:list',
|
|
55
|
+
summary: AgentsList.summary,
|
|
56
|
+
examples: AgentsList.examples,
|
|
57
|
+
requiredScopes: ['cli:agents'],
|
|
58
|
+
mutates: false,
|
|
59
|
+
confirm: 'none',
|
|
60
|
+
jsonSchemaId: 'revition.agents.list.v1',
|
|
61
|
+
stability: 'beta',
|
|
62
|
+
};
|
|
63
|
+
async run2(ctx) {
|
|
64
|
+
const api = await agentsApi(ctx);
|
|
65
|
+
return { agents: (await api.request({ method: 'GET', path: '/deployments' })).body.items };
|
|
66
|
+
}
|
|
67
|
+
human(o) {
|
|
68
|
+
if (o.agents.length === 0)
|
|
69
|
+
return { text: 'No agents in this workspace yet. Create one with `revition agents create <file>`.\n' };
|
|
70
|
+
return {
|
|
71
|
+
text: renderTable(['id', 'name', 'status'], o.agents.map((a) => [a.deploymentId, a.name, a.status ?? '-']), terminalTable()),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/agents/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,eAAe,EACf,IAAI,EACJ,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,GAKX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAwC,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAmB;IACjD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,MAAM,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACnK,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,C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EAAE,aAAa;QACjB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,cAAc,EAAE,CAAC,YAAY,CAAC;QAC9B,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,yBAAyB;QACvC,SAAS,EAAE,MAAM;KAClB,CAAC;IAEQ,KAAK,CAAC,IAAI,CAAC,GAAmB;QACtC,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,EAAE,MAAM,EAAE,CAAC,MAAM,GAAG,CAAC,OAAO,CAA0B,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACtH,CAAC;IAEkB,KAAK,CAAC,CAAM;QAC7B,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,qFAAqF,EAAE,CAAC;QAClI,OAAO;YACL,IAAI,EAAE,WAAW,CACf,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EACxB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,EAC9D,aAAa,EAAE,CAChB;SACF,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RevitionCommand, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
export declare const OPEN_ACTIONS: readonly ["publish", "promote"];
|
|
3
|
+
/**
|
|
4
|
+
* The portal page where a person publishes an agent's draft or promotes an environment: the agent's page, the same
|
|
5
|
+
* page the server names when it refuses a CLI token on those routes (sentinel/cli-scopes human-only-routes.ts
|
|
6
|
+
* portalUrlFor: `/deployments/...` -> `/foundry/agents/{id}`). PURE.
|
|
7
|
+
*/
|
|
8
|
+
export declare function agentPageUrl(agentId: string): string;
|
|
9
|
+
/** Only Revition pages over https are opened. */
|
|
10
|
+
export declare function assertRevitionPage(url: string): string;
|
|
11
|
+
interface Out {
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
readonly action: (typeof OPEN_ACTIONS)[number] | null;
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly opened: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** T3.1.4 - `revition agents open <id> [--action publish|promote]`: the human step's page (D9: the CLI never publishes). */
|
|
18
|
+
export default class AgentsOpen extends RevitionCommand<Out> {
|
|
19
|
+
static summary: string;
|
|
20
|
+
static examples: string[];
|
|
21
|
+
static meta: CommandMeta;
|
|
22
|
+
static args: {
|
|
23
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
24
|
+
};
|
|
25
|
+
static flags: {
|
|
26
|
+
action: import("@oclif/core/interfaces").OptionFlag<"publish" | "promote" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
};
|
|
28
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
29
|
+
protected human(o: Out): HumanView;
|
|
30
|
+
}
|
|
31
|
+
export {};
|