@aui.io/apollo 0.1.21 → 0.1.25
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 +183 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.js +34 -9
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/bundles.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/curl.d.ts +10 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/curl.js +63 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/curl.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/doctor.d.ts +13 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/doctor.js +89 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/doctor.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/hierarchy.js +24 -7
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/hierarchy.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/runtime-version.d.ts +10 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/runtime-version.js +116 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/runtime-version.js.map +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/scenarios.js +3 -3
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/scenarios.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/status.js +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/commands/status.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/index.d.ts +1 -0
- package/node_modules/@aui.io/apollo-cli/dist/src/index.js +26 -1
- package/node_modules/@aui.io/apollo-cli/dist/src/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-cli/package.json +3 -3
- package/node_modules/@aui.io/apollo-core/dist/src/api/agent-settings.d.ts +166 -26
- package/node_modules/@aui.io/apollo-core/dist/src/api/agent-settings.js +106 -20
- package/node_modules/@aui.io/apollo-core/dist/src/api/agent-settings.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/api/capture.d.ts +22 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/capture.js +75 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/capture.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/management.d.ts +0 -1
- package/node_modules/@aui.io/apollo-core/dist/src/api/management.js +0 -6
- package/node_modules/@aui.io/apollo-core/dist/src/api/management.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/api/network.d.ts +19 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/network.js +53 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/network.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.d.ts +14 -2
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.js +15 -28
- package/node_modules/@aui.io/apollo-core/dist/src/api/transport.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/config/index.d.ts +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/config/index.js +16 -1
- package/node_modules/@aui.io/apollo-core/dist/src/config/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/config/store.d.ts +10 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/store.js +24 -0
- package/node_modules/@aui.io/apollo-core/dist/src/config/store.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/config/types.d.ts +18 -1
- package/node_modules/@aui.io/apollo-core/dist/src/index.d.ts +10 -5
- package/node_modules/@aui.io/apollo-core/dist/src/index.js +9 -4
- package/node_modules/@aui.io/apollo-core/dist/src/index.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/runtime-version/index.d.ts +72 -0
- package/node_modules/@aui.io/apollo-core/dist/src/runtime-version/index.js +114 -0
- package/node_modules/@aui.io/apollo-core/dist/src/runtime-version/index.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/bundles.d.ts +47 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/bundles.js +60 -6
- package/node_modules/@aui.io/apollo-core/dist/src/services/bundles.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/clients.d.ts +4 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/clients.js +19 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/clients.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/doctor.d.ts +39 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/doctor.js +586 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/doctor.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/hierarchy.d.ts +78 -2
- package/node_modules/@aui.io/apollo-core/dist/src/services/hierarchy.js +177 -17
- package/node_modules/@aui.io/apollo-core/dist/src/services/hierarchy.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/requests.d.ts +22 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/requests.js +73 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/requests.js.map +1 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/scenarios.d.ts +15 -8
- package/node_modules/@aui.io/apollo-core/dist/src/services/scenarios.js +80 -58
- package/node_modules/@aui.io/apollo-core/dist/src/services/scenarios.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/dist/src/services/status.service.d.ts +2 -0
- package/node_modules/@aui.io/apollo-core/dist/src/services/status.service.js +10 -2
- package/node_modules/@aui.io/apollo-core/dist/src/services/status.service.js.map +1 -1
- package/node_modules/@aui.io/apollo-core/package.json +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/registry.js +16 -2
- package/node_modules/@aui.io/apollo-tui/dist/src/actions/registry.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivityDrawer.js +31 -16
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/ActivityDrawer.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/requests.d.ts +19 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/requests.js +29 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/activity/requests.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/author/AuthorHome.d.ts +3 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/author/AuthorHome.js +6 -18
- package/node_modules/@aui.io/apollo-tui/dist/src/author/AuthorHome.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/author/ResourcesView.js +26 -4
- package/node_modules/@aui.io/apollo-tui/dist/src/author/ResourcesView.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/context/ContextSwitcher.js +6 -2
- package/node_modules/@aui.io/apollo-tui/dist/src/context/ContextSwitcher.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/actions.js +95 -16
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/actions.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.d.ts +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.js +20 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/commands.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/diagnostics.d.ts +8 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/diagnostics.js +109 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/diagnostics.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.d.ts +2 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.js +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/lib/scope.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.js +2 -2
- package/node_modules/@aui.io/apollo-tui/dist/src/opentui-app.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/Breadcrumb.d.ts +4 -2
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/Breadcrumb.js +5 -3
- package/node_modules/@aui.io/apollo-tui/dist/src/shell/Breadcrumb.js.map +1 -1
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/SplashCard.d.ts +5 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/SplashCard.js +56 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/SplashCard.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/wordmark.d.ts +73 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/wordmark.js +488 -0
- package/node_modules/@aui.io/apollo-tui/dist/src/ui/wordmark.js.map +1 -0
- package/node_modules/@aui.io/apollo-tui/package.json +2 -2
- package/package.json +4 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { AgentSettingsClient } from "../api/agent-settings.js";
|
|
1
2
|
import type { IdentityClient, Organization } from "../api/identity.js";
|
|
2
3
|
import { type Agent, type AgentVersion, type ManagementClient, type Project } from "../api/management.js";
|
|
4
|
+
import type { NetworkClient } from "../api/network.js";
|
|
3
5
|
import { type Context, type ProjectBinding } from "../config/index.js";
|
|
4
6
|
export declare function listOrganizations(identity: IdentityClient): Promise<Organization[]>;
|
|
5
7
|
export declare function useOrganization(context: Context, identity: IdentityClient, organizationId: string): Promise<{
|
|
@@ -20,8 +22,46 @@ export declare function createProject(context: Context, management: ManagementCl
|
|
|
20
22
|
export declare function listAgents(context: Context, management: ManagementClient, name?: string): Promise<{
|
|
21
23
|
results: Agent[];
|
|
22
24
|
}>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The template a new agent is cloned from — "General Runtime-v2", a published,
|
|
27
|
+
* blob-mode `template`-kind agent in agent-settings. Apollo's own create
|
|
28
|
+
* endpoint picks a template by category, i.e. whatever the environment's
|
|
29
|
+
* default `GENERAL` category holds, so the console names the runtime-v2 one
|
|
30
|
+
* outright instead. Override per create with `agent create --template <id>`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TEMPLATE_AGENT_ID = "6a63896e1bd618f292ba6684";
|
|
33
|
+
/** The two services `createAgent` drives, in the order it touches them. */
|
|
34
|
+
export interface AgentCreateClients {
|
|
35
|
+
agentSettings: AgentSettingsClient;
|
|
36
|
+
network: NetworkClient;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create an agent by running the clone-from-template sequence the console
|
|
40
|
+
* needs, against agent-settings and the network service directly. It is
|
|
41
|
+
* step-for-step what apollo-api's create endpoint does internally — the only
|
|
42
|
+
* difference is that the template is named here rather than resolved from a
|
|
43
|
+
* category:
|
|
44
|
+
*
|
|
45
|
+
* 1. read the template — its category scopes the new agent, its metadata
|
|
46
|
+
* seeds the record, and it must already have an active version;
|
|
47
|
+
* 2. allocate the network the agent is scoped to (agent-settings requires a
|
|
48
|
+
* network id for a `regular` agent, and one network hosts one agent);
|
|
49
|
+
* 3. create the agent root (`regular`, blob mode);
|
|
50
|
+
* 4. draft from the template — the load-bearing step: agent-settings clones
|
|
51
|
+
* the bundle, the build bundle and the evaluation scores into the agent;
|
|
52
|
+
* 5. publish that draft and activate it, so the agent answers immediately;
|
|
53
|
+
* 6. draft again off the published version — the mutable copy authoring
|
|
54
|
+
* edits, and the tag a fresh checkout binds.
|
|
55
|
+
*
|
|
56
|
+
* The sequence is not transactional. Everything checkable is checked before
|
|
57
|
+
* the first write; past that, a failure leaves the agent behind and says so,
|
|
58
|
+
* because a blind re-run would allocate a second network and a second agent.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createAgent(context: Context, clients: AgentCreateClients, name: string, templateAgentId?: string): Promise<Agent>;
|
|
61
|
+
export declare function bindAgent(context: Context, agent: Agent, cwd: string, options?: {
|
|
62
|
+
versionTag?: string;
|
|
63
|
+
runtimeVersion?: string;
|
|
64
|
+
}): Promise<ProjectBinding>;
|
|
25
65
|
/**
|
|
26
66
|
* The tag a fresh `agent create` checkout should bind so the authoring loop
|
|
27
67
|
* completes from the first push (REPORTS-26 defect 1): the server seeds a
|
|
@@ -33,6 +73,42 @@ export declare function bindAgent(context: Context, agent: Agent, cwd: string, v
|
|
|
33
73
|
* already succeeded remotely — `version use` recovers.
|
|
34
74
|
*/
|
|
35
75
|
export declare function initialVersionTag(management: ManagementClient, agent: Agent): Promise<string | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* The engine build a fresh checkout pins — the runtime half of what
|
|
78
|
+
* `initialVersionTag` does for the agent's own version. Create and import
|
|
79
|
+
* answer this differently on purpose, so there are two functions rather than
|
|
80
|
+
* one with a mode.
|
|
81
|
+
*
|
|
82
|
+
* Both are best-effort, like `initialVersionTag`: `undefined` leaves the
|
|
83
|
+
* checkout unpinned rather than failing a create or import that already
|
|
84
|
+
* succeeded remotely, and an unpinned checkout is exactly what every checkout
|
|
85
|
+
* was before pinning existed. `apollo runtime use` recovers.
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* What a NEW agent starts on: the newest PUBLISHED runtime in the catalog.
|
|
89
|
+
* A fresh agent has no history to honour, so it should begin on the current
|
|
90
|
+
* engine. Custom entries are bespoke deployments and the legacy 1.x family
|
|
91
|
+
* cannot run a schema-2 bundle, so neither is ever chosen here.
|
|
92
|
+
*/
|
|
93
|
+
export declare function latestPublishedRuntimeVersion(clients: {
|
|
94
|
+
agentSettings: AgentSettingsClient;
|
|
95
|
+
}): Promise<string | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* What an EXISTING agent already runs on: the value the agent record itself
|
|
98
|
+
* carries (`active_blob_stats.runtime_version` — agent-settings only, since
|
|
99
|
+
* apollo's projection drops it).
|
|
100
|
+
*
|
|
101
|
+
* Taken VERBATIM, including families the catalog has since hidden. Importing
|
|
102
|
+
* is meant to reproduce the agent as it is; resolving through the catalog
|
|
103
|
+
* would silently move an agent onto a runtime it was never run on, which is
|
|
104
|
+
* a decision for `apollo runtime use` to make explicitly.
|
|
105
|
+
*
|
|
106
|
+
* An agent with nothing pushed yet (or an unreadable record) has no runtime
|
|
107
|
+
* of its own, so it starts where a new agent would.
|
|
108
|
+
*/
|
|
109
|
+
export declare function agentRuntimeVersion(clients: {
|
|
110
|
+
agentSettings: AgentSettingsClient;
|
|
111
|
+
}, agentId: string): Promise<string | undefined>;
|
|
36
112
|
/**
|
|
37
113
|
* Bind a version tag in the current checkout — the push base / pull default.
|
|
38
114
|
* The missing leg of selection symmetry (org/project/agent had `use`,
|
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { findLiveVersion, } from "../api/management.js";
|
|
4
|
-
import { setDefaultProject, writeBinding, } from "../config/index.js";
|
|
5
|
-
import { ConfigError } from "../errors/index.js";
|
|
4
|
+
import { patchBinding, setDefaultProject, writeBinding, } from "../config/index.js";
|
|
5
|
+
import { AuthError, CliError, ConfigError } from "../errors/index.js";
|
|
6
|
+
import { resolveRuntimeVersion } from "../runtime-version/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* Patch the checkout's existing `.apollorc`. Bindings are never invented in
|
|
8
9
|
* arbitrary directories — outside a checkout, selection goes to the
|
|
9
10
|
* account-level default project instead.
|
|
11
|
+
*
|
|
12
|
+
* Fields the patch does not mention survive untouched; a field set to
|
|
13
|
+
* `undefined` is deleted (how `agent unlink` clears the agent and tag).
|
|
10
14
|
*/
|
|
11
15
|
async function updateBinding(context, patch) {
|
|
12
16
|
if (!context.bindingPath) {
|
|
13
17
|
throw new ConfigError("No agent checkout here (.apollorc not found).");
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
config_version: 1,
|
|
19
|
+
return patchBinding(context.bindingPath, {
|
|
17
20
|
...(context.orgId ? { org_id: context.orgId } : {}),
|
|
18
21
|
...(context.projectId ? { project_id: context.projectId } : {}),
|
|
19
22
|
...(context.agentId ? { agent_id: context.agentId } : {}),
|
|
20
23
|
...(context.versionTag ? { version_tag: context.versionTag } : {}),
|
|
21
24
|
...patch,
|
|
22
|
-
};
|
|
23
|
-
for (const [key, value] of Object.entries(binding)) {
|
|
24
|
-
if (value === undefined) {
|
|
25
|
-
delete binding[key];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
await writeBinding(context.bindingPath, binding);
|
|
29
|
-
return binding;
|
|
25
|
+
});
|
|
30
26
|
}
|
|
31
27
|
async function selectProject(context, project, homeDir) {
|
|
32
28
|
// Inside a checkout the .apollorc is the selection; keep agent identity
|
|
@@ -83,18 +79,137 @@ export async function listAgents(context, management, name) {
|
|
|
83
79
|
// Unlike /projects, the agents endpoint filters by name server-side.
|
|
84
80
|
return management.listAgents(context.projectId, name);
|
|
85
81
|
}
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
/**
|
|
83
|
+
* The template a new agent is cloned from — "General Runtime-v2", a published,
|
|
84
|
+
* blob-mode `template`-kind agent in agent-settings. Apollo's own create
|
|
85
|
+
* endpoint picks a template by category, i.e. whatever the environment's
|
|
86
|
+
* default `GENERAL` category holds, so the console names the runtime-v2 one
|
|
87
|
+
* outright instead. Override per create with `agent create --template <id>`.
|
|
88
|
+
*/
|
|
89
|
+
export const TEMPLATE_AGENT_ID = "6a63896e1bd618f292ba6684";
|
|
90
|
+
/**
|
|
91
|
+
* Project an agent-settings record onto the published agent shape, the same
|
|
92
|
+
* way apollo-api does: the id is the record's own, `project_id` is the scope's
|
|
93
|
+
* account and `live_version_id` carries the active *tag* (REPORTS-26).
|
|
94
|
+
*/
|
|
95
|
+
function agentFromRecord(record, projectId) {
|
|
96
|
+
return {
|
|
97
|
+
id: record.id,
|
|
98
|
+
project_id: record.scope.account_id ?? projectId,
|
|
99
|
+
name: record.name,
|
|
100
|
+
...(record.active_version_tag === undefined
|
|
101
|
+
? {}
|
|
102
|
+
: { live_version_id: record.active_version_tag }),
|
|
103
|
+
created_at: record.created_at,
|
|
104
|
+
updated_at: record.updated_at,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create an agent by running the clone-from-template sequence the console
|
|
109
|
+
* needs, against agent-settings and the network service directly. It is
|
|
110
|
+
* step-for-step what apollo-api's create endpoint does internally — the only
|
|
111
|
+
* difference is that the template is named here rather than resolved from a
|
|
112
|
+
* category:
|
|
113
|
+
*
|
|
114
|
+
* 1. read the template — its category scopes the new agent, its metadata
|
|
115
|
+
* seeds the record, and it must already have an active version;
|
|
116
|
+
* 2. allocate the network the agent is scoped to (agent-settings requires a
|
|
117
|
+
* network id for a `regular` agent, and one network hosts one agent);
|
|
118
|
+
* 3. create the agent root (`regular`, blob mode);
|
|
119
|
+
* 4. draft from the template — the load-bearing step: agent-settings clones
|
|
120
|
+
* the bundle, the build bundle and the evaluation scores into the agent;
|
|
121
|
+
* 5. publish that draft and activate it, so the agent answers immediately;
|
|
122
|
+
* 6. draft again off the published version — the mutable copy authoring
|
|
123
|
+
* edits, and the tag a fresh checkout binds.
|
|
124
|
+
*
|
|
125
|
+
* The sequence is not transactional. Everything checkable is checked before
|
|
126
|
+
* the first write; past that, a failure leaves the agent behind and says so,
|
|
127
|
+
* because a blind re-run would allocate a second network and a second agent.
|
|
128
|
+
*/
|
|
129
|
+
export async function createAgent(context, clients, name, templateAgentId = TEMPLATE_AGENT_ID) {
|
|
130
|
+
const projectId = context.projectId;
|
|
131
|
+
if (!projectId)
|
|
88
132
|
throw new ConfigError("Select a project first.");
|
|
89
|
-
|
|
133
|
+
const organizationId = context.orgId;
|
|
134
|
+
if (!organizationId) {
|
|
135
|
+
throw new ConfigError("Select an organization first.", "Run `apollo org use` and try again.");
|
|
136
|
+
}
|
|
137
|
+
// Stamped as created_by/published_by on every record the sequence writes.
|
|
138
|
+
const userId = context.userId;
|
|
139
|
+
if (!userId) {
|
|
140
|
+
throw new AuthError("The stored credential has no user id.", "Run `apollo login` again to refresh it.");
|
|
141
|
+
}
|
|
142
|
+
// Everything below is checked here rather than left to the server: past the
|
|
143
|
+
// network call these would each fail with an agent already created.
|
|
144
|
+
const template = await clients.agentSettings.getAgent(templateAgentId);
|
|
145
|
+
if (template.kind !== "template") {
|
|
146
|
+
throw new ConfigError(`Agent ${templateAgentId} is not a template (kind=${template.kind}).`, "Pass a template agent's id with --template.");
|
|
147
|
+
}
|
|
148
|
+
const categoryId = template.scope.network_category_id;
|
|
149
|
+
if (!categoryId) {
|
|
150
|
+
throw new ConfigError(`Template ${template.name} has no category scope to create the agent in.`, "Pass a different template agent's id with --template.");
|
|
151
|
+
}
|
|
152
|
+
// The clone reads the template's *active* version, not its latest.
|
|
153
|
+
if (!template.active_version_id) {
|
|
154
|
+
throw new ConfigError(`Template ${template.name} has no active version to clone.`, "Publish and activate a version on the template, or pass --template <id>.");
|
|
155
|
+
}
|
|
156
|
+
const network = await clients.network.create({
|
|
157
|
+
name,
|
|
158
|
+
organizationId,
|
|
159
|
+
accountId: projectId,
|
|
160
|
+
categoryId,
|
|
161
|
+
});
|
|
162
|
+
const created = await clients.agentSettings.createAgent({
|
|
163
|
+
name,
|
|
164
|
+
scope: {
|
|
165
|
+
type: "NETWORK",
|
|
166
|
+
network_id: network.id,
|
|
167
|
+
account_id: projectId,
|
|
168
|
+
organization_id: organizationId,
|
|
169
|
+
network_category_id: categoryId,
|
|
170
|
+
},
|
|
171
|
+
kind: "regular",
|
|
172
|
+
bundleMode: true,
|
|
173
|
+
createdBy: userId,
|
|
174
|
+
agentMetadata: template.agent_metadata ?? {},
|
|
175
|
+
});
|
|
176
|
+
try {
|
|
177
|
+
const imported = await clients.agentSettings.createDraft(created.id, {
|
|
178
|
+
source: "template",
|
|
179
|
+
fromTemplate: template.id,
|
|
180
|
+
label: "Template Import",
|
|
181
|
+
notes: `Imported from template ${template.name}`,
|
|
182
|
+
createdBy: userId,
|
|
183
|
+
});
|
|
184
|
+
await clients.agentSettings.publishVersion(created.id, imported.id, userId);
|
|
185
|
+
const live = await clients.agentSettings.activateVersion(created.id, imported.id);
|
|
186
|
+
await clients.agentSettings.createDraft(created.id, {
|
|
187
|
+
source: "version",
|
|
188
|
+
fromVersion: imported.id,
|
|
189
|
+
label: "Initial Version",
|
|
190
|
+
notes: "Initial Version",
|
|
191
|
+
createdBy: userId,
|
|
192
|
+
});
|
|
193
|
+
return agentFromRecord(live, projectId);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
throw new CliError(`Agent ${created.name} (${created.id}) was created, but seeding its first version from ${template.name} failed: ${error instanceof Error ? error.message : String(error)}`, {
|
|
197
|
+
code: "AGENT_SEED_FAILED",
|
|
198
|
+
cause: error,
|
|
199
|
+
suggestion: `Do not re-run create — it would allocate a second agent. Recover with \`apollo agent import ${created.id}\` or seed a version with \`apollo version create --template ${template.id}\`.`,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
90
202
|
}
|
|
91
|
-
export async function bindAgent(context, agent, cwd,
|
|
203
|
+
export async function bindAgent(context, agent, cwd, options = {}) {
|
|
92
204
|
const binding = {
|
|
93
205
|
config_version: 1,
|
|
94
206
|
...(context.orgId ? { org_id: context.orgId } : {}),
|
|
95
207
|
project_id: agent.project_id,
|
|
96
208
|
agent_id: agent.id,
|
|
97
|
-
...(versionTag ? { version_tag: versionTag } : {}),
|
|
209
|
+
...(options.versionTag ? { version_tag: options.versionTag } : {}),
|
|
210
|
+
...(options.runtimeVersion
|
|
211
|
+
? { runtime_version: options.runtimeVersion }
|
|
212
|
+
: {}),
|
|
98
213
|
};
|
|
99
214
|
await writeBinding(path.join(cwd, ".apollorc"), binding);
|
|
100
215
|
return binding;
|
|
@@ -121,6 +236,51 @@ export async function initialVersionTag(management, agent) {
|
|
|
121
236
|
return undefined;
|
|
122
237
|
}
|
|
123
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* The engine build a fresh checkout pins — the runtime half of what
|
|
241
|
+
* `initialVersionTag` does for the agent's own version. Create and import
|
|
242
|
+
* answer this differently on purpose, so there are two functions rather than
|
|
243
|
+
* one with a mode.
|
|
244
|
+
*
|
|
245
|
+
* Both are best-effort, like `initialVersionTag`: `undefined` leaves the
|
|
246
|
+
* checkout unpinned rather than failing a create or import that already
|
|
247
|
+
* succeeded remotely, and an unpinned checkout is exactly what every checkout
|
|
248
|
+
* was before pinning existed. `apollo runtime use` recovers.
|
|
249
|
+
*/
|
|
250
|
+
/**
|
|
251
|
+
* What a NEW agent starts on: the newest PUBLISHED runtime in the catalog.
|
|
252
|
+
* A fresh agent has no history to honour, so it should begin on the current
|
|
253
|
+
* engine. Custom entries are bespoke deployments and the legacy 1.x family
|
|
254
|
+
* cannot run a schema-2 bundle, so neither is ever chosen here.
|
|
255
|
+
*/
|
|
256
|
+
export async function latestPublishedRuntimeVersion(clients) {
|
|
257
|
+
return (await resolveRuntimeVersion(clients.agentSettings)).version;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* What an EXISTING agent already runs on: the value the agent record itself
|
|
261
|
+
* carries (`active_blob_stats.runtime_version` — agent-settings only, since
|
|
262
|
+
* apollo's projection drops it).
|
|
263
|
+
*
|
|
264
|
+
* Taken VERBATIM, including families the catalog has since hidden. Importing
|
|
265
|
+
* is meant to reproduce the agent as it is; resolving through the catalog
|
|
266
|
+
* would silently move an agent onto a runtime it was never run on, which is
|
|
267
|
+
* a decision for `apollo runtime use` to make explicitly.
|
|
268
|
+
*
|
|
269
|
+
* An agent with nothing pushed yet (or an unreadable record) has no runtime
|
|
270
|
+
* of its own, so it starts where a new agent would.
|
|
271
|
+
*/
|
|
272
|
+
export async function agentRuntimeVersion(clients, agentId) {
|
|
273
|
+
try {
|
|
274
|
+
const record = await clients.agentSettings.getAgent(agentId);
|
|
275
|
+
const recorded = record.active_blob_stats?.runtime_version?.trim();
|
|
276
|
+
if (recorded)
|
|
277
|
+
return recorded;
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
// Not readable through agent-settings — fall through to the catalog.
|
|
281
|
+
}
|
|
282
|
+
return latestPublishedRuntimeVersion(clients);
|
|
283
|
+
}
|
|
124
284
|
/**
|
|
125
285
|
* Bind a version tag in the current checkout — the push base / pull default.
|
|
126
286
|
* The missing leg of selection symmetry (org/project/agent had `use`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchy.js","sourceRoot":"","sources":["../../../src/services/hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"hierarchy.js","sourceRoot":"","sources":["../../../src/services/hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EACL,eAAe,GAKhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;;;GAOG;AACH,KAAK,UAAU,aAAa,CAC1B,OAAgB,EAChB,KAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,MAAM,IAAI,WAAW,CAAC,+CAA+C,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE;QACvC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,G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;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAgB;IAChD,OAAO,aAAa,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,SAAS;KACvB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RequestCapture } from "../api/transport.js";
|
|
2
|
+
export interface CaptureFilters {
|
|
3
|
+
/** Keep only requests with HTTP status ≥ 400 or no response at all. */
|
|
4
|
+
failed?: boolean;
|
|
5
|
+
/** Keep only this HTTP method (case-insensitive). */
|
|
6
|
+
method?: string;
|
|
7
|
+
/** Keep only URLs containing this substring (case-insensitive). */
|
|
8
|
+
search?: string;
|
|
9
|
+
/** After other filters, keep only the most recent n entries. */
|
|
10
|
+
last?: number;
|
|
11
|
+
}
|
|
12
|
+
/** A request failed if the server said ≥ 400 — or never answered. */
|
|
13
|
+
export declare function captureFailed(entry: RequestCapture): boolean;
|
|
14
|
+
/** Read the persisted capture file; missing or malformed → empty list. */
|
|
15
|
+
export declare function readCapturedRequests(filePath?: string): Promise<RequestCapture[]>;
|
|
16
|
+
export declare function filterCaptures(entries: readonly RequestCapture[], filters: CaptureFilters): RequestCapture[];
|
|
17
|
+
/**
|
|
18
|
+
* One capture as a runnable curl command. Redacted (`***`) auth-ish header
|
|
19
|
+
* values become `$APOLLO_TOKEN` inside double quotes so the shell expands
|
|
20
|
+
* them at paste time; every other redacted value stays `***` verbatim.
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatCurl(entry: RequestCapture): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Captured-request reading and curl formatting — the read side of the
|
|
3
|
+
* capture pipeline (api/capture.ts), consumed by `apollo curl` and the TUI.
|
|
4
|
+
*
|
|
5
|
+
* Everything here works on redacted entries: secrets never reach the disk
|
|
6
|
+
* (transport.ts redacts before capture), so replay output substitutes
|
|
7
|
+
* `$APOLLO_TOKEN` for redacted auth-ish headers instead of pretending the
|
|
8
|
+
* real value exists.
|
|
9
|
+
*/
|
|
10
|
+
import { readFile } from "node:fs/promises";
|
|
11
|
+
import { defaultCapturePath } from "../api/capture.js";
|
|
12
|
+
/** A request failed if the server said ≥ 400 — or never answered. */
|
|
13
|
+
export function captureFailed(entry) {
|
|
14
|
+
return entry.status === undefined || entry.status >= 400;
|
|
15
|
+
}
|
|
16
|
+
/** Read the persisted capture file; missing or malformed → empty list. */
|
|
17
|
+
export async function readCapturedRequests(filePath = defaultCapturePath()) {
|
|
18
|
+
let raw;
|
|
19
|
+
try {
|
|
20
|
+
raw = await readFile(filePath, "utf8");
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const parsed = JSON.parse(raw);
|
|
27
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function filterCaptures(entries, filters) {
|
|
34
|
+
let result = [...entries];
|
|
35
|
+
if (filters.failed === true)
|
|
36
|
+
result = result.filter(captureFailed);
|
|
37
|
+
if (filters.method !== undefined) {
|
|
38
|
+
const method = filters.method.toUpperCase();
|
|
39
|
+
result = result.filter((entry) => entry.method.toUpperCase() === method);
|
|
40
|
+
}
|
|
41
|
+
if (filters.search !== undefined && filters.search !== "") {
|
|
42
|
+
const needle = filters.search.toLowerCase();
|
|
43
|
+
result = result.filter((entry) => entry.url.toLowerCase().includes(needle));
|
|
44
|
+
}
|
|
45
|
+
if (filters.last !== undefined && filters.last > 0) {
|
|
46
|
+
result = result.slice(-filters.last);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
|
|
51
|
+
/**
|
|
52
|
+
* One capture as a runnable curl command. Redacted (`***`) auth-ish header
|
|
53
|
+
* values become `$APOLLO_TOKEN` inside double quotes so the shell expands
|
|
54
|
+
* them at paste time; every other redacted value stays `***` verbatim.
|
|
55
|
+
*/
|
|
56
|
+
export function formatCurl(entry) {
|
|
57
|
+
const lines = [`curl -X ${entry.method} ${shellQuote(entry.url)}`];
|
|
58
|
+
for (const [name, value] of Object.entries(entry.headers)) {
|
|
59
|
+
if (value === "***" && /authorization|token/i.test(name)) {
|
|
60
|
+
const replacement = name.toLowerCase() === "authorization"
|
|
61
|
+
? "Bearer $APOLLO_TOKEN"
|
|
62
|
+
: "$APOLLO_TOKEN";
|
|
63
|
+
lines.push(` -H "${name}: ${replacement}"`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
lines.push(` -H ${shellQuote(`${name}: ${value}`)}`);
|
|
67
|
+
}
|
|
68
|
+
if (entry.body !== undefined) {
|
|
69
|
+
lines.push(` --data ${shellQuote(JSON.stringify(entry.body))}`);
|
|
70
|
+
}
|
|
71
|
+
return lines.join(" \\\n");
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../../src/services/requests.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAcvD,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AAC3D,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAQ,GAAG,kBAAkB,EAAE;IAE/B,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC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promise<LocalScor
|
|
|
49
49
|
export declare function writeLocalScores(checkoutRoot: string, data: LocalScores): Promise<void>;
|
|
50
50
|
/** Absolute paths of every file directly under `scenarios/intent/`. */
|
|
51
51
|
export declare function listIntentFiles(checkoutRoot: string): Promise<string[]>;
|
|
52
|
+
/** Every file under `scenarios/` except `scores.json`, as relative POSIX paths. */
|
|
53
|
+
export declare function listBundleFiles(checkoutRoot: string): Promise<{
|
|
54
|
+
rel: string;
|
|
55
|
+
abs: string;
|
|
56
|
+
}[]>;
|
|
52
57
|
/**
|
|
53
58
|
* Pre-flight the suite against the server contract so a push fails here
|
|
54
59
|
* with a clear message instead of a remote 422. Returns the scenarios.
|
|
55
60
|
*/
|
|
56
61
|
export declare function validateScenariosFile(file: ScenariosFile): LocalScenario[];
|
|
57
62
|
export interface AssembledBundle {
|
|
58
|
-
|
|
59
|
-
intents: BundleUploadFile[];
|
|
63
|
+
files: BundleUploadFile[];
|
|
60
64
|
scenariosCount: number;
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
67
|
* Assemble a bundle push from the checkout: the validated suite plus every
|
|
64
|
-
*
|
|
65
|
-
*
|
|
68
|
+
* other file under `scenarios/` except `scores.json`. Throws when the suite
|
|
69
|
+
* is missing/invalid or a file is too large.
|
|
66
70
|
*/
|
|
67
71
|
export declare function assembleBundleUpload(checkoutRoot: string): Promise<AssembledBundle>;
|
|
68
72
|
export interface PushBundleResult {
|
|
69
73
|
version: number;
|
|
70
74
|
scenariosCount: number;
|
|
75
|
+
filesCount: number;
|
|
71
76
|
intentsCount: number;
|
|
72
77
|
}
|
|
73
|
-
/** Push the checkout's
|
|
78
|
+
/** Push the checkout's scenarios tree as a new bundle version. */
|
|
74
79
|
export declare function pushScenarioBundle(context: Context, params?: {
|
|
75
80
|
notes?: string;
|
|
76
81
|
}, options?: ScenariosServiceOptions): Promise<PushBundleResult>;
|
|
@@ -102,12 +107,13 @@ export interface PullScenariosResult {
|
|
|
102
107
|
found: boolean;
|
|
103
108
|
version?: number;
|
|
104
109
|
scenariosCount?: number;
|
|
110
|
+
filesCount?: number;
|
|
105
111
|
intentsCount?: number;
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
|
-
* Pull the latest (or a specific) bundle into `scenarios/`:
|
|
109
|
-
*
|
|
110
|
-
*
|
|
114
|
+
* Pull the latest (or a specific) bundle into `scenarios/`: downloads every
|
|
115
|
+
* file via its signed URL. `found: false` (no throw) when the agent has no
|
|
116
|
+
* bundle yet.
|
|
111
117
|
*/
|
|
112
118
|
export declare function pullScenarios(context: Context, params?: {
|
|
113
119
|
bundleVersion?: number;
|
|
@@ -129,6 +135,7 @@ export interface SyncScenariosResult {
|
|
|
129
135
|
found: boolean;
|
|
130
136
|
version?: number;
|
|
131
137
|
scenariosCount?: number;
|
|
138
|
+
filesCount?: number;
|
|
132
139
|
intentsCount?: number;
|
|
133
140
|
scoresFound?: boolean;
|
|
134
141
|
/** Set when the pull failed; callers note it but do NOT fail. */
|