@inneranimalmedia/agentsam-sdk 2.4.1 → 2.6.0
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/AGENTSAM.md +55 -0
- package/README.md +17 -12
- package/bin/agentsam +2 -0
- package/docs/AGENTSAM_ASTRA_OPENAI_INTEGRATION.md +1363 -0
- package/docs/AGENTSAM_WORKBENCH.md +30 -0
- package/docs/AUTH_IDENTITY_CONTRACT.md +52 -0
- package/docs/CAPABILITIES.md +5 -3
- package/docs/CLI_SHELL.md +167 -80
- package/docs/CMS_STUDIO.md +101 -0
- package/docs/CONTEXT.md +170 -0
- package/docs/LOCAL_OLLAMA.md +58 -0
- package/docs/MERKLE.md +19 -19
- package/docs/PORTABLE_CONTEXT.md +4 -3
- package/docs/PROJECT_CONFIG.md +72 -0
- package/docs/RELEASES.md +35 -2
- package/docs/REPOSITORY_INTELLIGENCE.md +1 -1
- package/docs/REPOSITORY_KNOWLEDGE.md +114 -0
- package/docs/SDK_WORKER.md +86 -0
- package/docs/SECURITY.md +59 -22
- package/docs/client-cms-editor.md +15 -0
- package/docs/local-studio/WORKMODE_DONOR_NOTES.md +485 -0
- package/package.json +35 -10
- package/packages/connectors/cloudflare/package.json +10 -0
- package/packages/connectors/cloudflare/src/index.js +127 -0
- package/packages/connectors/cloudflare/src/owner.js +76 -0
- package/packages/connectors/cloudflare/src/routes.js +223 -0
- package/packages/connectors/cloudflare/src/vault.js +80 -0
- package/packages/connectors/cloudflare/tests/connector.test.mjs +44 -0
- package/packages/identity/package.json +10 -1
- package/packages/identity/src/contracts/auth-config.js +109 -0
- package/packages/identity/src/index.js +1 -0
- package/packages/identity/src/oauth/README.md +2 -2
- package/packages/identity/src/oauth/credentials.js +11 -4
- package/packages/identity/src/oauth/iam-platform.js +3 -3
- package/packages/identity/src/providers/iam/index.js +7 -7
- package/packages/identity/src/providers/iam/oauth.js +6 -4
- package/packages/identity/src/providers/iam/profile.js +5 -5
- package/packages/identity/tests/auth-config.test.mjs +61 -0
- package/packages/identity/tests/oauth-credentials.test.mjs +13 -2
- package/protocol/FILEMETA_V1.md +95 -0
- package/protocol/INSPECT_VIEWS_V1.md +40 -0
- package/protocol/MERKLE_PERSISTENCE_V1.md +50 -0
- package/protocol/MERKLE_V1.md +3 -1
- package/protocol/README.md +1 -0
- package/protocol/capabilities/cloudflare-cpu-audit-input.schema.json +19 -0
- package/protocol/capabilities/cloudflare-cpu-profile-input.schema.json +13 -0
- package/protocol/capabilities/cloudflare-wrangler-native-input.schema.json +19 -0
- package/protocol/capabilities/manifest.json +79 -3
- package/protocol/capabilities/repository-snapshot.schema.json +1 -0
- package/protocol/context/context-budget.schema.json +36 -0
- package/protocol/context/context-item.schema.json +19 -0
- package/protocol/context/resolved-context-pack.schema.json +47 -0
- package/protocol/context/result-policy.schema.json +17 -0
- package/protocol/knowledge/context-pack.schema.json +33 -0
- package/protocol/knowledge/retrieval-query.schema.json +68 -13
- package/protocol/models/README.md +373 -0
- package/protocol/models/model-inventory-v2.schema.json +212 -0
- package/python/README.md +15 -7
- package/python/agentsam_sdk/cli.py +0 -21
- package/python/agentsam_sdk/tui/README.md +17 -12
- package/python/agentsam_sdk/tui/bootstrap.py +2 -2
- package/python/agentsam_sdk/tui/demo.py +25 -10
- package/python/agentsam_sdk/tui/onboarding.py +208 -0
- package/python/tests/test_tui_cli.py +7 -6
- package/skills/README.md +21 -0
- package/skills/agentsam-app-fundamentals/SKILL.md +165 -0
- package/skills/agentsam-app-fundamentals/references/graphs-contracts-ast-merkle.md +89 -0
- package/skills/agentsam-app-fundamentals/references/trust-credentials-and-destinations.md +99 -0
- package/skills/agentsam-cloudflare-workers/SKILL.md +53 -0
- package/skills/agentsam-cloudflare-workers/references/cpu-profiling.md +16 -0
- package/skills/agentsam-cloudflare-workers/references/errors-and-observability.md +29 -0
- package/skills/agentsam-cloudflare-workers/references/wrangler-native-map.md +28 -0
- package/skills/agentsam-jr-dev/SKILL.md +232 -0
- package/skills/agentsam-jr-dev/references/real-application-logic.md +156 -0
- package/skills/agentsam-jr-dev/references/web-application-fundamentals.md +240 -0
- package/skills/agentsam-progression-guard/SKILL.md +197 -0
- package/skills/agentsam-progression-guard/references/checkpoint-chain.md +111 -0
- package/skills/agentsam-progression-guard/references/hooks-operational-io.md +96 -0
- package/skills/catalog.json +71 -0
- package/src/agent/capability-adapter.js +25 -13
- package/src/agent/index.js +1 -0
- package/src/agent/responses-runner.js +325 -0
- package/src/capabilities/index.js +7 -0
- package/src/capabilities/repository-snapshot-view.js +238 -0
- package/src/capabilities/repository-snapshot.js +28 -14
- package/src/cli.js +198 -76
- package/src/cloudflare/cpu-profile.js +115 -0
- package/src/cloudflare/index.js +14 -0
- package/src/cloudflare/wrangler.js +132 -0
- package/src/commands/account-auth.js +47 -0
- package/src/commands/cloudflare.js +58 -0
- package/src/commands/connections.js +93 -0
- package/src/commands/context-economics.js +114 -0
- package/src/commands/context.js +14 -2
- package/src/commands/db.js +4 -7
- package/src/commands/deploy.js +54 -32
- package/src/commands/eval.js +63 -0
- package/src/commands/interactive.js +18 -0
- package/src/commands/knowledge.js +27 -4
- package/src/commands/merkle-persist.js +118 -0
- package/src/commands/merkle.js +32 -17
- package/src/commands/models.js +152 -0
- package/src/commands/ollama.js +259 -0
- package/src/commands/preferences.js +144 -0
- package/src/commands/product.js +86 -16
- package/src/commands/resume.js +67 -0
- package/src/commands/security.js +8 -6
- package/src/commands/shell.js +405 -100
- package/src/commands/skills.js +66 -0
- package/src/commands/start-local.js +1 -1
- package/src/commands/tunnel.js +5 -4
- package/src/commands/whoami.js +86 -0
- package/src/context/budget.js +120 -0
- package/src/context/compact.js +28 -0
- package/src/context/index.js +7 -0
- package/src/context/rehydrate.js +35 -0
- package/src/context/resolve.js +116 -0
- package/src/context/result-policy.js +66 -0
- package/src/errors/diagnostic.js +160 -0
- package/src/errors/index.js +9 -0
- package/src/eval/context.js +191 -0
- package/src/eval/index.js +1 -0
- package/src/index.js +70 -0
- package/src/indexing/execution-boundary.js +144 -0
- package/src/indexing/index.js +8 -0
- package/src/indexing/provider.js +41 -0
- package/src/knowledge/config.js +2 -2
- package/src/knowledge/context-pack.js +12 -1
- package/src/knowledge/contracts.js +9 -4
- package/src/knowledge/engine.js +7 -3
- package/src/knowledge/service/server.js +1 -1
- package/src/lib/account-session.js +98 -0
- package/src/lib/agent-instructions.js +73 -0
- package/src/lib/auth.js +4 -0
- package/src/lib/bridge-client.js +7 -5
- package/src/lib/cli-preferences.js +78 -0
- package/src/lib/core-client.js +8 -8
- package/src/lib/deploy/git-guard.js +69 -0
- package/src/lib/deploy/health.js +57 -0
- package/src/lib/deploy/local-studio.js +283 -0
- package/src/lib/deploy/secret-scan.js +65 -0
- package/src/lib/deploy-receipt/index.js +5 -2
- package/src/lib/detect-context.js +6 -5
- package/src/lib/execution-approvals.js +59 -0
- package/src/lib/identity-scaffold.js +1 -1
- package/src/lib/local-scaffold.js +35 -33
- package/src/lib/local-sessions.js +127 -0
- package/src/lib/local-status.js +9 -17
- package/src/lib/merkle/cloudflare-persistence.js +321 -0
- package/src/lib/merkle/filemeta.js +43 -0
- package/src/lib/merkle/git-ignore.js +24 -0
- package/src/lib/merkle/hash.js +1 -0
- package/src/lib/merkle/index.js +22 -0
- package/src/lib/merkle/persistence.js +72 -0
- package/src/lib/merkle/semantic.js +359 -0
- package/src/lib/merkle/snapshot.js +9 -3
- package/src/lib/merkle/tree.js +11 -6
- package/src/lib/project-config.js +227 -0
- package/src/lib/project-rules.js +68 -0
- package/src/lib/provider-credentials.js +83 -0
- package/src/lib/save-sdk-token.js +1 -1
- package/src/lib/scaffold/templates/worker-api/index.js +101 -20
- package/src/lib/scaffold/wizards/worker-api.js +27 -11
- package/src/lib/slash-commands.js +22 -15
- package/src/lib/tools.js +11 -5
- package/src/models/catalog.js +135 -0
- package/src/models/index.js +7 -0
- package/src/providers/index.js +5 -0
- package/src/providers/openai-responses.js +275 -0
- package/src/security/index.js +1 -0
- package/src/security/inventory.js +4 -1
- package/src/security/process.js +35 -9
- package/src/security/render.js +27 -5
- package/src/security/scan.js +24 -9
- package/src/security/trust-boundary.js +24 -0
- package/src/skills/index.js +64 -0
- package/src/telemetry/contracts.js +203 -0
- package/src/telemetry/events.js +48 -0
- package/src/telemetry/index.js +8 -0
- package/src/tools/hydrate.js +35 -0
- package/src/tools/index.js +2 -0
- package/src/tools/search.js +70 -0
- package/src/ui/ansi.js +1 -1
- package/src/ui/boot.js +54 -0
- package/src/ui/merkle/render.js +1 -0
- package/src/ui/runtime-activity.js +192 -0
- package/src/ui/theme.js +19 -18
- package/test/account-session.test.mjs +36 -0
- package/test/app-building-skills.test.mjs +61 -0
- package/test/apps-scaffold-contract.test.mjs +56 -0
- package/test/capabilities.test.mjs +53 -4
- package/test/cli-preferences.test.mjs +46 -0
- package/test/cloudflare-connector.test.mjs +96 -0
- package/test/cloudflare-runtime.test.mjs +75 -0
- package/test/context.test.mjs +144 -0
- package/test/deploy-health-scan.test.mjs +67 -0
- package/test/error-diagnostics.test.mjs +59 -0
- package/test/eval-context.test.mjs +37 -0
- package/test/execution-approvals.test.mjs +27 -0
- package/test/indexing-provider.test.mjs +29 -0
- package/test/jr-dev-skill.test.mjs +26 -0
- package/test/knowledge-context-pack.test.mjs +19 -0
- package/test/knowledge.test.mjs +1 -1
- package/test/local-sessions.test.mjs +42 -0
- package/test/local-studio-deploy.test.mjs +83 -0
- package/test/merkle-persistence.test.mjs +91 -0
- package/test/merkle.test.mjs +77 -3
- package/test/model-catalog.test.mjs +43 -0
- package/test/models.test.mjs +51 -0
- package/test/npm10-lock.test.mjs +29 -0
- package/test/ollama.test.mjs +94 -0
- package/test/openai-responses.test.mjs +95 -0
- package/test/project-config.test.mjs +81 -0
- package/test/project-rules.test.mjs +44 -0
- package/test/provider-credentials.test.mjs +52 -0
- package/test/rehydrate.test.mjs +25 -0
- package/test/release-hygiene.test.mjs +34 -0
- package/test/repository-snapshot-view.test.mjs +112 -0
- package/test/responses-runner.test.mjs +148 -0
- package/test/runtime-activity.test.mjs +98 -0
- package/test/sdk-worker-contract.test.mjs +68 -0
- package/test/security.test.mjs +46 -0
- package/test/shell.test.mjs +55 -21
- package/test/skills.test.mjs +22 -0
- package/test/smoke.mjs +5 -2
- package/test/telemetry.test.mjs +79 -0
- package/test/theme-portability.test.mjs +14 -0
- package/test/tools-search.test.mjs +40 -0
- package/test/whoami-resume.test.mjs +56 -0
- package/examples/agentsam-tui-ansi.mjs +0 -149
- package/src/commands/tui.js +0 -120
- package/src/ui/splash-xterm.js +0 -290
- package/src/ui/splash.js +0 -426
package/src/cli.js
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
import pkg from '../package.json' with { type: 'json' };
|
|
4
4
|
import readline from 'readline';
|
|
5
|
+
import { cancel, intro, isCancel, outro, select, text } from '@clack/prompts';
|
|
5
6
|
import path from 'node:path';
|
|
6
|
-
import { buildLocalScaffoldMeta
|
|
7
|
+
import { buildLocalScaffoldMeta } from './lib/local-scaffold.js';
|
|
7
8
|
import { writeScaffoldFiles } from './lib/write-files.js';
|
|
8
9
|
import { initializeGitRepository } from './lib/init-git.js';
|
|
9
10
|
import { initializeLocalSqlite } from './local/sqlite.js';
|
|
10
11
|
import { printContextSummary } from './lib/detect-context.js';
|
|
11
12
|
import { promptOptionalByokKeys } from './lib/prompt-byok.js';
|
|
12
13
|
import { runStartLocal } from './commands/start-local.js';
|
|
14
|
+
import { runOllama } from './commands/ollama.js';
|
|
15
|
+
import { runModels } from './commands/models.js';
|
|
13
16
|
import { runTunnel } from './commands/tunnel.js';
|
|
14
17
|
import { runDeploy } from './commands/deploy.js';
|
|
18
|
+
import { runConnections } from './commands/connections.js';
|
|
15
19
|
import { runIdentityPreview } from './commands/identity-preview.js';
|
|
16
20
|
import { runIdentityInit } from './commands/identity-init.js';
|
|
17
21
|
import { runContext } from './commands/context.js';
|
|
18
22
|
import { runDb } from './commands/db.js';
|
|
19
23
|
import { runStatus } from './commands/status.js';
|
|
20
|
-
import {
|
|
24
|
+
import { runInteractive } from './commands/interactive.js';
|
|
21
25
|
import { runShell } from './commands/shell.js';
|
|
22
26
|
import { runDockerize } from './commands/dockerize.js';
|
|
23
27
|
import { runMini } from './commands/mini.js';
|
|
@@ -26,13 +30,27 @@ import { runDeployReceipt } from './commands/deploy-receipt.js';
|
|
|
26
30
|
import { runSecurity } from './commands/security.js';
|
|
27
31
|
import { runRecon } from './commands/recon.js';
|
|
28
32
|
import { runCad } from './commands/cad.js';
|
|
33
|
+
import { runSkills } from './commands/skills.js';
|
|
34
|
+
import { runEval } from './commands/eval.js';
|
|
35
|
+
import { runCloudflare } from './commands/cloudflare.js';
|
|
36
|
+
import { runWhoami } from './commands/whoami.js';
|
|
37
|
+
import { runResume } from './commands/resume.js';
|
|
38
|
+
import { runLogin, runLogout } from './commands/account-auth.js';
|
|
29
39
|
import { applyPresetSelection, runAdd, runCapabilities, runDev, runInspect } from './commands/product.js';
|
|
30
40
|
import { listPresets, resolvePreset } from './presets/index.js';
|
|
31
41
|
import fs from 'node:fs';
|
|
32
42
|
import { repositoryRoot } from './knowledge/config.js';
|
|
43
|
+
import { resolveAccountSdkKey } from './lib/account-session.js';
|
|
44
|
+
import { renderDiagnosticError } from './errors/index.js';
|
|
33
45
|
|
|
34
46
|
const VERSION = pkg.version;
|
|
35
47
|
|
|
48
|
+
function reportCliError(error) {
|
|
49
|
+
if (error?.reported) return;
|
|
50
|
+
const rendered = renderDiagnosticError(error).split('\n').map((line) => ` ${line}`).join('\n');
|
|
51
|
+
console.error(`\n${rendered}\n`);
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
function createPrompt() {
|
|
37
55
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
38
56
|
return {
|
|
@@ -46,14 +64,16 @@ function printHelp() {
|
|
|
46
64
|
Agent Sam SDK — CLI v${VERSION}
|
|
47
65
|
|
|
48
66
|
Product UX:
|
|
67
|
+
agentsam Enter the interactive Agent Sam experience
|
|
49
68
|
agentsam create <name> --preset <fullstack|cms|prototype|data>
|
|
50
69
|
agentsam add <auth|cms|knowledge|agent|deploy-cloudflare>
|
|
51
70
|
agentsam dev Run this project's existing npm dev script
|
|
52
|
-
agentsam inspect [--json]
|
|
71
|
+
agentsam inspect [--json] Bounded repository index by default; use --view full for authority envelope
|
|
53
72
|
agentsam deploy Graduate an AgentSam project intentionally
|
|
54
73
|
|
|
55
74
|
Capability discovery:
|
|
56
75
|
agentsam capabilities [capability-id] [--json]
|
|
76
|
+
agentsam skills [skill-id-or-alias] [--references] [--json]
|
|
57
77
|
|
|
58
78
|
Power-user UX:
|
|
59
79
|
agentsam context [--json] Git repo/revision + bridge configuration from any repo
|
|
@@ -63,15 +83,21 @@ function printHelp() {
|
|
|
63
83
|
agentsam repo snapshot Git composition/churn; --save retains observations
|
|
64
84
|
agentsam cad blender Programmatic Blender inspect/build/render/export (--help)
|
|
65
85
|
agentsam mini <name> Create and preview a small local gadget (--help for options)
|
|
66
|
-
agentsam merkle File integrity, snapshots, comparisons, and
|
|
86
|
+
agentsam merkle File integrity, snapshots, comparisons, and interactive explorer (--help)
|
|
67
87
|
agentsam deploy-receipt Merkle deploy/checkpoint capture + promote/failure receipts (--help)
|
|
68
88
|
agentsam recon Bounded-worker task packets + finding-report validation (--help)
|
|
69
89
|
agentsam security Dependency scan, log triage, and verified repair (--help)
|
|
70
90
|
agentsam status [--json] Live local Git + DB + API + PTY status
|
|
71
91
|
agentsam db init|status Manage the project-local SQLite database
|
|
72
|
-
agentsam
|
|
73
|
-
agentsam
|
|
92
|
+
agentsam models Verify configured providers and selectable hosted/local models
|
|
93
|
+
agentsam login Authenticate IAM and persist a secure machine-local session
|
|
94
|
+
agentsam logout Remove the local IAM session; provider keys stay untouched
|
|
95
|
+
agentsam whoami [--json] Authenticated IAM identity + safe credential status
|
|
96
|
+
agentsam resume [session] Resume a saved Agent Sam session; omit id for picker
|
|
97
|
+
agentsam eval context Offline context-strategy/economics fixtures (--help)
|
|
98
|
+
agentsam cloudflare Native Wrangler reads + Worker CPU profile analysis (--help)
|
|
74
99
|
agentsam start-local Local PTY on ws://127.0.0.1:3099 (no tunnel, no Cloudflare)
|
|
100
|
+
agentsam ollama Opt-in local Ollama setup/status/model management
|
|
75
101
|
agentsam shell Interactive Agent Sam slash-command shell
|
|
76
102
|
agentsam tunnel Explicitly expose local PTY when remote access is wanted
|
|
77
103
|
agentsam deploy Graduate to Cloudflare / GCP when ready
|
|
@@ -84,6 +110,21 @@ function printHelp() {
|
|
|
84
110
|
Context options:
|
|
85
111
|
--json Machine-readable output
|
|
86
112
|
--cwd <path> Resolve a different working directory
|
|
113
|
+
|
|
114
|
+
Inspect options:
|
|
115
|
+
--view <full|index|files> Full authority envelope, facet index, or bounded matching files (default index)
|
|
116
|
+
--full Explicitly request the full authority envelope
|
|
117
|
+
--system/--package <name> Filter semantic ownership
|
|
118
|
+
--category/--tag <value> Filter semantic classification
|
|
119
|
+
--layer/--role <value> Filter architecture role
|
|
120
|
+
--path <prefix|glob> Filter repository paths (supports * and **)
|
|
121
|
+
--symbol/--import <value> Filter AST symbols or imports
|
|
122
|
+
--match <text> Lexical AND-match across semantic routing metadata
|
|
123
|
+
--limit <1..500> Bound files view (default 50)
|
|
124
|
+
--facet-limit <1..200> Bound each facet list (default 48)
|
|
125
|
+
--snapshot-file <file> Reuse a saved canonical repository.snapshot; skips Merkle/AST rescan
|
|
126
|
+
--save-snapshot <file> Save the canonical full snapshot while emitting the selected view
|
|
127
|
+
--pretty Pretty-print JSON; machine JSON is compact by default
|
|
87
128
|
--remote <name> Preferred Git remote (default origin; falls back to first remote)
|
|
88
129
|
|
|
89
130
|
Init is completable with Node only — no IAM login, no OAuth, no Cloudflare.
|
|
@@ -93,7 +134,7 @@ function printHelp() {
|
|
|
93
134
|
--quick Quick tunnel (default) — trycloudflare.com URL
|
|
94
135
|
--named Named CF tunnel (needs --tunnel-name --hostname --zone-id)
|
|
95
136
|
--port <n> Local PTY port (default 3099)
|
|
96
|
-
--token <sdk_…> Use existing
|
|
137
|
+
--token <sdk_…> Use existing AGENTSAM_SDK_KEY (skip browser auth)
|
|
97
138
|
|
|
98
139
|
Init options:
|
|
99
140
|
--name <name> Project directory name
|
|
@@ -121,11 +162,13 @@ function parseInitArgs(argv) {
|
|
|
121
162
|
}
|
|
122
163
|
|
|
123
164
|
function parseDeployArgs(argv) {
|
|
124
|
-
const opts = { target: '', accountId: '' };
|
|
165
|
+
const opts = { target: '', accountId: '', dryRun: false, plan: false };
|
|
125
166
|
for (let i = 0; i < argv.length; i += 1) {
|
|
126
167
|
const arg = argv[i];
|
|
127
168
|
if (arg === '--target') opts.target = argv[++i] || '';
|
|
128
169
|
else if (arg === '--account-id') opts.accountId = argv[++i] || '';
|
|
170
|
+
else if (arg === '--dry-run') opts.dryRun = true;
|
|
171
|
+
else if (arg === '--plan') opts.plan = true;
|
|
129
172
|
}
|
|
130
173
|
return opts;
|
|
131
174
|
}
|
|
@@ -176,7 +219,7 @@ async function runLocalInit(config) {
|
|
|
176
219
|
✓ Environment ${path.join(dir, '.env')}
|
|
177
220
|
✓ SQLite ${db.dbPath} (${db.tables.length} tables)
|
|
178
221
|
✓ Local API Node · http://127.0.0.1:8787
|
|
179
|
-
✓
|
|
222
|
+
✓ Agent Sam interactive CLI ready
|
|
180
223
|
|
|
181
224
|
Next:`);
|
|
182
225
|
console.log(` cd ${meta.projectName}`);
|
|
@@ -184,9 +227,10 @@ async function runLocalInit(config) {
|
|
|
184
227
|
console.log(` ${step}`);
|
|
185
228
|
}
|
|
186
229
|
|
|
187
|
-
|
|
230
|
+
const sdkKey = resolveAccountSdkKey({ env: process.env }).value;
|
|
231
|
+
if (prompt && sdkKey) {
|
|
188
232
|
console.log('\n Optional — BYOK keys for IAM dashboard Agent Sam (skip with Enter):\n');
|
|
189
|
-
await promptOptionalByokKeys(
|
|
233
|
+
await promptOptionalByokKeys(sdkKey, prompt);
|
|
190
234
|
}
|
|
191
235
|
|
|
192
236
|
console.log(`
|
|
@@ -196,58 +240,61 @@ async function runLocalInit(config) {
|
|
|
196
240
|
}
|
|
197
241
|
|
|
198
242
|
async function initInteractive(partial = {}) {
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
`);
|
|
207
|
-
|
|
208
|
-
const projectName =
|
|
209
|
-
partial.projectName ||
|
|
210
|
-
(await prompt.ask(' 1) Project name: '));
|
|
211
|
-
|
|
212
|
-
if (!partial.lane) {
|
|
213
|
-
console.log(`
|
|
214
|
-
2) Lane:
|
|
215
|
-
1) Full Stack 2) CMS 3) Data 4) CRM 5) Creative
|
|
216
|
-
`);
|
|
217
|
-
}
|
|
218
|
-
const laneKey = partial.lane
|
|
219
|
-
? partial.lane
|
|
220
|
-
: LANE_KEYS[await prompt.ask(' Pick lane [1-5]: ')] || 'fullstack';
|
|
243
|
+
const pick = (value) => {
|
|
244
|
+
if (!isCancel(value)) return value;
|
|
245
|
+
cancel('Agent Sam init cancelled.');
|
|
246
|
+
const error = new Error('init_cancelled');
|
|
247
|
+
error.code = 'AGENTSAM_INIT_CANCELLED';
|
|
248
|
+
throw error;
|
|
249
|
+
};
|
|
221
250
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
intro('Create an Agent Sam project');
|
|
252
|
+
|
|
253
|
+
const projectName = partial.projectName || pick(await text({
|
|
254
|
+
message: 'Project name',
|
|
255
|
+
placeholder: 'my-agent',
|
|
256
|
+
validate(value) {
|
|
257
|
+
if (!String(value || '').trim()) return 'Project name is required';
|
|
258
|
+
},
|
|
259
|
+
}));
|
|
260
|
+
|
|
261
|
+
const laneKey = partial.lane || pick(await select({
|
|
262
|
+
message: 'Project type',
|
|
263
|
+
initialValue: 'fullstack',
|
|
264
|
+
options: [
|
|
265
|
+
{ value: 'fullstack', label: 'Full Stack' },
|
|
266
|
+
{ value: 'cms', label: 'CMS' },
|
|
267
|
+
{ value: 'data', label: 'Data Solutions' },
|
|
268
|
+
{ value: 'crm', label: 'Customer Management' },
|
|
269
|
+
{ value: 'creative', label: 'Creative & Design' },
|
|
270
|
+
],
|
|
271
|
+
}));
|
|
272
|
+
|
|
273
|
+
const runTarget = partial.runTarget || pick(await select({
|
|
274
|
+
message: 'Future deploy target',
|
|
275
|
+
initialValue: 'local',
|
|
276
|
+
options: [
|
|
277
|
+
{ value: 'local', label: 'Local only / decide later' },
|
|
278
|
+
{ value: 'cloudflare', label: 'Cloudflare later' },
|
|
279
|
+
{ value: 'gcp', label: 'GCP later' },
|
|
280
|
+
],
|
|
281
|
+
}));
|
|
225
282
|
|
|
226
|
-
1) Local only / decide later
|
|
227
|
-
2) Cloudflare later (Worker + D1 adapter at deploy time)
|
|
228
|
-
3) GCP later (your Google Cloud project)
|
|
229
|
-
`);
|
|
230
|
-
}
|
|
231
|
-
const runTarget = partial.runTarget
|
|
232
|
-
? partial.runTarget
|
|
233
|
-
: RUN_TARGETS[await prompt.ask(' Select [1]: ')] || 'local';
|
|
234
|
-
|
|
235
|
-
// Credential detection is demand-driven, not unconditional. missingForInit()
|
|
236
|
-
// already knows local needs nothing (`if (runTarget === 'local') return []`)
|
|
237
|
-
// — it just never got consulted before this fix, because detectContext()
|
|
238
|
-
// used to run before runTarget was even known. runTarget alone is enough
|
|
239
|
-
// to decide whether detection is needed at all, so skip the subprocess
|
|
240
|
-
// calls entirely for local instead of just hiding their output.
|
|
241
283
|
if (runTarget !== 'local') {
|
|
242
284
|
const { detectContext, missingForInit } = await import('./lib/detect-context.js');
|
|
243
285
|
const ctx = await detectContext();
|
|
244
|
-
if (missingForInit(ctx, process.env.
|
|
286
|
+
if (missingForInit(ctx, resolveAccountSdkKey({ env: process.env }).value, { runTarget }).length) {
|
|
245
287
|
printContextSummary(ctx);
|
|
246
288
|
}
|
|
247
289
|
}
|
|
248
290
|
|
|
249
|
-
|
|
250
|
-
|
|
291
|
+
const prompt = resolveAccountSdkKey({ env: process.env }).value ? createPrompt() : null;
|
|
292
|
+
try {
|
|
293
|
+
await runLocalInit({ projectName, lane: laneKey, runTarget, prompt });
|
|
294
|
+
} finally {
|
|
295
|
+
prompt?.close();
|
|
296
|
+
}
|
|
297
|
+
outro(`Created ${projectName}`);
|
|
251
298
|
}
|
|
252
299
|
|
|
253
300
|
async function initFromArgs(argv) {
|
|
@@ -264,8 +311,20 @@ const rest = process.argv.slice(3);
|
|
|
264
311
|
|
|
265
312
|
if (command === '--version' || command === '-v') {
|
|
266
313
|
console.log(VERSION);
|
|
267
|
-
} else if (command === '--help' || command === '-h'
|
|
314
|
+
} else if (command === '--help' || command === '-h') {
|
|
268
315
|
printHelp();
|
|
316
|
+
} else if (!command) {
|
|
317
|
+
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
318
|
+
try { await runInteractive(); }
|
|
319
|
+
catch (e) {
|
|
320
|
+
if (e?.code !== 'AGENTSAM_SETUP_CANCELLED') {
|
|
321
|
+
reportCliError(e);
|
|
322
|
+
process.exitCode = 1;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
} else {
|
|
326
|
+
printHelp();
|
|
327
|
+
}
|
|
269
328
|
} else if (command === 'create') {
|
|
270
329
|
try {
|
|
271
330
|
const opts = parseCreateArgs(rest);
|
|
@@ -277,86 +336,149 @@ if (command === '--version' || command === '-v') {
|
|
|
277
336
|
applyPresetSelection(created.dir, preset);
|
|
278
337
|
console.log(` ✓ Preset ${preset.id}\n ✓ Features ${preset.features.join(', ') || 'none'}\n ✓ Capabilities ${preset.capabilities.length}\n`);
|
|
279
338
|
}
|
|
280
|
-
} catch (e) {
|
|
339
|
+
} catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
281
340
|
} else if (command === 'add') {
|
|
282
341
|
try { await runAdd(rest); }
|
|
283
|
-
catch (e) {
|
|
342
|
+
catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
284
343
|
} else if (command === 'dev') {
|
|
285
344
|
try { await runDev(rest); }
|
|
286
|
-
catch (e) {
|
|
345
|
+
catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
287
346
|
} else if (command === 'inspect') {
|
|
288
347
|
try { await runInspect(rest); }
|
|
289
|
-
catch (e) {
|
|
348
|
+
catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
290
349
|
} else if (command === 'capabilities') {
|
|
291
350
|
try { await runCapabilities(rest); }
|
|
292
|
-
catch (e) {
|
|
351
|
+
catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
293
352
|
} else if (command === 'context') {
|
|
294
353
|
try {
|
|
295
354
|
await runContext(rest);
|
|
296
355
|
} catch (e) {
|
|
297
|
-
|
|
356
|
+
reportCliError(e);
|
|
298
357
|
process.exit(1);
|
|
299
358
|
}
|
|
300
359
|
} else if (command === 'status') {
|
|
301
360
|
try {
|
|
302
361
|
await runStatus(rest);
|
|
303
362
|
} catch (e) {
|
|
304
|
-
|
|
363
|
+
reportCliError(e);
|
|
305
364
|
process.exit(1);
|
|
306
365
|
}
|
|
307
366
|
} else if (command === 'db') {
|
|
308
367
|
try {
|
|
309
368
|
await runDb(rest);
|
|
310
369
|
} catch (e) {
|
|
311
|
-
|
|
370
|
+
reportCliError(e);
|
|
312
371
|
process.exit(1);
|
|
313
372
|
}
|
|
314
|
-
} else if (command === '
|
|
373
|
+
} else if (command === 'models') {
|
|
315
374
|
try {
|
|
316
|
-
await
|
|
375
|
+
await runModels(rest);
|
|
317
376
|
} catch (e) {
|
|
318
|
-
|
|
377
|
+
reportCliError(e);
|
|
319
378
|
process.exit(1);
|
|
320
379
|
}
|
|
380
|
+
} else if (command === 'eval') {
|
|
381
|
+
try {
|
|
382
|
+
await runEval(rest);
|
|
383
|
+
} catch (e) {
|
|
384
|
+
reportCliError(e);
|
|
385
|
+
process.exit(1);
|
|
386
|
+
}
|
|
387
|
+
} else if (command === 'cloudflare' || command === 'cf') {
|
|
388
|
+
try {
|
|
389
|
+
await runCloudflare(rest);
|
|
390
|
+
} catch (e) {
|
|
391
|
+
if (!e?.reported) reportCliError(e);
|
|
392
|
+
process.exitCode = 1;
|
|
393
|
+
}
|
|
394
|
+
} else if (command === 'login') {
|
|
395
|
+
try {
|
|
396
|
+
await runLogin(rest);
|
|
397
|
+
} catch (e) {
|
|
398
|
+
reportCliError(e);
|
|
399
|
+
process.exitCode = 1;
|
|
400
|
+
}
|
|
401
|
+
} else if (command === 'logout') {
|
|
402
|
+
try {
|
|
403
|
+
runLogout(rest);
|
|
404
|
+
} catch (e) {
|
|
405
|
+
reportCliError(e);
|
|
406
|
+
process.exitCode = 1;
|
|
407
|
+
}
|
|
408
|
+
} else if (command === 'whoami') {
|
|
409
|
+
try {
|
|
410
|
+
await runWhoami(rest);
|
|
411
|
+
} catch (e) {
|
|
412
|
+
reportCliError(e);
|
|
413
|
+
process.exitCode = 1;
|
|
414
|
+
}
|
|
415
|
+
} else if (command === 'resume') {
|
|
416
|
+
try {
|
|
417
|
+
await runResume(rest);
|
|
418
|
+
} catch (e) {
|
|
419
|
+
reportCliError(e);
|
|
420
|
+
process.exitCode = 1;
|
|
421
|
+
}
|
|
321
422
|
} else if (command === 'shell') {
|
|
322
423
|
try {
|
|
323
424
|
await runShell(rest);
|
|
324
425
|
} catch (e) {
|
|
325
|
-
|
|
426
|
+
reportCliError(e);
|
|
326
427
|
process.exit(1);
|
|
327
428
|
}
|
|
328
429
|
} else if (command === 'start-local') {
|
|
329
430
|
await runStartLocal({});
|
|
431
|
+
} else if (command === 'ollama') {
|
|
432
|
+
try {
|
|
433
|
+
await runOllama(rest);
|
|
434
|
+
} catch (e) {
|
|
435
|
+
reportCliError(e);
|
|
436
|
+
process.exitCode = 1;
|
|
437
|
+
}
|
|
330
438
|
} else if (command === 'tunnel') {
|
|
331
439
|
try {
|
|
332
440
|
await runTunnel(rest);
|
|
333
441
|
} catch (e) {
|
|
334
|
-
|
|
442
|
+
reportCliError(e);
|
|
443
|
+
process.exit(1);
|
|
444
|
+
}
|
|
445
|
+
} else if (command === 'connections' || command === 'connection') {
|
|
446
|
+
try {
|
|
447
|
+
await runConnections(rest);
|
|
448
|
+
} catch (e) {
|
|
449
|
+
reportCliError(e);
|
|
335
450
|
process.exit(1);
|
|
336
451
|
}
|
|
337
452
|
} else if (command === 'deploy') {
|
|
338
453
|
try {
|
|
339
454
|
await runDeploy(parseDeployArgs(rest));
|
|
340
455
|
} catch (e) {
|
|
341
|
-
|
|
456
|
+
reportCliError(e);
|
|
342
457
|
process.exit(1);
|
|
343
458
|
}
|
|
344
459
|
} else if (command === 'dockerize') {
|
|
345
460
|
try {
|
|
346
461
|
await runDockerize(rest);
|
|
347
462
|
} catch (e) {
|
|
348
|
-
|
|
463
|
+
reportCliError(e);
|
|
349
464
|
process.exit(1);
|
|
350
465
|
}
|
|
351
466
|
} else if (command === 'cad') {
|
|
352
467
|
try {
|
|
353
468
|
await runCad(rest);
|
|
354
469
|
} catch (e) {
|
|
355
|
-
|
|
470
|
+
reportCliError(e);
|
|
356
471
|
process.exitCode = 1;
|
|
357
472
|
}
|
|
358
473
|
} else if (command === 'security' || command === 'sca') {
|
|
359
474
|
await runSecurity(rest);
|
|
475
|
+
} else if (command === 'skills' || command === 'skill') {
|
|
476
|
+
try {
|
|
477
|
+
runSkills(rest);
|
|
478
|
+
} catch (e) {
|
|
479
|
+
reportCliError(e);
|
|
480
|
+
process.exitCode = 1;
|
|
481
|
+
}
|
|
360
482
|
} else if (command === 'merkle') {
|
|
361
483
|
await runMerkle(rest);
|
|
362
484
|
} else if (command === 'deploy-receipt') {
|
|
@@ -367,14 +489,14 @@ if (command === '--version' || command === '-v') {
|
|
|
367
489
|
try {
|
|
368
490
|
await runMini(rest);
|
|
369
491
|
} catch (e) {
|
|
370
|
-
|
|
492
|
+
reportCliError(e);
|
|
371
493
|
process.exitCode = 1;
|
|
372
494
|
}
|
|
373
495
|
} else if (['index', 'search', 'repo'].includes(command)) {
|
|
374
496
|
try {
|
|
375
497
|
const commands = await import('./commands/knowledge.js');
|
|
376
498
|
await ({ index: commands.runKnowledge, search: commands.runSearch, repo: commands.runRepository })[command](rest);
|
|
377
|
-
} catch (e) {
|
|
499
|
+
} catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
378
500
|
} else if (command === 'init') {
|
|
379
501
|
try {
|
|
380
502
|
const existing = !rest.includes('--name') && (rest.includes('.') || rest.includes('--existing') || rest.includes('--cwd') || fs.existsSync(path.join(repositoryRoot(), '.git')));
|
|
@@ -382,21 +504,21 @@ if (command === '--version' || command === '-v') {
|
|
|
382
504
|
else if (rest.includes('--help') || rest.includes('-h')) printHelp();
|
|
383
505
|
else if (rest.some((a) => a.startsWith('--'))) await initFromArgs(rest);
|
|
384
506
|
else await initInteractive({});
|
|
385
|
-
} catch (e) {
|
|
507
|
+
} catch (e) { reportCliError(e); process.exitCode = 1; }
|
|
386
508
|
} else if (command === 'identity') {
|
|
387
509
|
const sub = rest[0];
|
|
388
510
|
if (sub === 'preview') {
|
|
389
511
|
try {
|
|
390
512
|
await runIdentityPreview(rest.slice(1));
|
|
391
513
|
} catch (e) {
|
|
392
|
-
|
|
514
|
+
reportCliError(e);
|
|
393
515
|
process.exit(1);
|
|
394
516
|
}
|
|
395
517
|
} else if (sub === 'init') {
|
|
396
518
|
try {
|
|
397
519
|
await runIdentityInit(rest);
|
|
398
520
|
} catch (e) {
|
|
399
|
-
|
|
521
|
+
reportCliError(e);
|
|
400
522
|
process.exit(1);
|
|
401
523
|
}
|
|
402
524
|
} else {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
function clean(value) { return value == null ? '' : String(value).trim(); }
|
|
5
|
+
function number(value) { const n = Number(value ?? 0); return Number.isFinite(n) && n >= 0 ? n : 0; }
|
|
6
|
+
|
|
7
|
+
function parseProfile(value) {
|
|
8
|
+
if (typeof value === 'string') return JSON.parse(value);
|
|
9
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new TypeError('Cloudflare CPU profile must be a Chrome .cpuprofile object');
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function frameOf(node = {}) {
|
|
14
|
+
const frame = node.callFrame || {};
|
|
15
|
+
return {
|
|
16
|
+
node_id: node.id,
|
|
17
|
+
function: clean(frame.functionName) || '(anonymous)',
|
|
18
|
+
url: clean(frame.url) || null,
|
|
19
|
+
line: Number.isInteger(frame.lineNumber) && frame.lineNumber >= 0 ? frame.lineNumber + 1 : null,
|
|
20
|
+
column: Number.isInteger(frame.columnNumber) && frame.columnNumber >= 0 ? frame.columnNumber + 1 : null,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function summarizeCloudflareCpuProfile(value, options = {}) {
|
|
25
|
+
const profile = parseProfile(value);
|
|
26
|
+
if (!Array.isArray(profile.nodes) || !Array.isArray(profile.samples)) throw new TypeError('CPU profile requires nodes[] and samples[]');
|
|
27
|
+
const deltas = Array.isArray(profile.timeDeltas) ? profile.timeDeltas : [];
|
|
28
|
+
const byId = new Map(profile.nodes.map((node) => [node.id, node]));
|
|
29
|
+
const totals = new Map();
|
|
30
|
+
let totalUs = 0;
|
|
31
|
+
for (let index = 0; index < profile.samples.length; index += 1) {
|
|
32
|
+
const id = profile.samples[index];
|
|
33
|
+
const deltaUs = number(deltas[index]);
|
|
34
|
+
totalUs += deltaUs;
|
|
35
|
+
totals.set(id, (totals.get(id) || 0) + deltaUs);
|
|
36
|
+
}
|
|
37
|
+
if (!totalUs && Number.isFinite(profile.endTime) && Number.isFinite(profile.startTime)) totalUs = Math.max(0, Number(profile.endTime) - Number(profile.startTime));
|
|
38
|
+
const maxFrames = Number.isInteger(options.maxFrames) && options.maxFrames > 0 ? Math.min(options.maxFrames, 100) : 25;
|
|
39
|
+
const frames = [...totals.entries()].map(([id, selfUs]) => {
|
|
40
|
+
const frame = frameOf(byId.get(id));
|
|
41
|
+
return Object.freeze({
|
|
42
|
+
...frame,
|
|
43
|
+
self_us: selfUs,
|
|
44
|
+
self_ms: selfUs / 1000,
|
|
45
|
+
percent: totalUs > 0 ? (selfUs / totalUs) * 100 : 0,
|
|
46
|
+
garbage_collection: /(?:garbage collector|\bgc\b)/i.test(frame.function),
|
|
47
|
+
});
|
|
48
|
+
}).sort((a, b) => b.self_us - a.self_us).slice(0, maxFrames);
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
schema_version: 1,
|
|
51
|
+
profile_kind: 'chrome-cpu-profile',
|
|
52
|
+
samples: profile.samples.length,
|
|
53
|
+
total_profile_us: totalUs,
|
|
54
|
+
total_profile_ms: totalUs / 1000,
|
|
55
|
+
top_frames: Object.freeze(frames),
|
|
56
|
+
garbage_collection_ms: frames.filter((row) => row.garbage_collection).reduce((sum, row) => sum + row.self_ms, 0),
|
|
57
|
+
timer_semantics: 'Deployed Workers timers do not advance during CPU-only execution; use local workerd/DevTools CPU profiles plus production CPU metrics.',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function within(root, file) { return file === root || file.startsWith(`${root}${path.sep}`); }
|
|
62
|
+
|
|
63
|
+
export function summarizeCloudflareCpuProfileFile(input = {}) {
|
|
64
|
+
const cwd = path.resolve(input.cwd || process.cwd());
|
|
65
|
+
const file = path.resolve(cwd, clean(input.file));
|
|
66
|
+
if (!clean(input.file)) throw new TypeError('cpu profile file is required');
|
|
67
|
+
if (!within(cwd, file)) throw new Error('cpu_profile_outside_cwd');
|
|
68
|
+
const stat = fs.statSync(file);
|
|
69
|
+
if (!stat.isFile()) throw new Error('cpu_profile_not_file');
|
|
70
|
+
if (stat.size > 64 * 1024 * 1024) throw new Error('cpu_profile_too_large');
|
|
71
|
+
return Object.freeze({ file: path.relative(cwd, file) || path.basename(file), ...summarizeCloudflareCpuProfile(fs.readFileSync(file, 'utf8'), input) });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sourceItems(cwd, sources = [], maxChars = 24_000) {
|
|
75
|
+
const rows = [];
|
|
76
|
+
let chars = 0;
|
|
77
|
+
for (const source of sources.slice(0, 12)) {
|
|
78
|
+
const file = path.resolve(cwd, String(source));
|
|
79
|
+
if (!within(cwd, file) || !fs.existsSync(file) || !fs.statSync(file).isFile()) continue;
|
|
80
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
81
|
+
const excerpt = text.slice(0, Math.min(8_000, Math.max(0, maxChars - chars)));
|
|
82
|
+
if (!excerpt) break;
|
|
83
|
+
rows.push(Object.freeze({ ref: `file:${path.relative(cwd, file)}`, chars: excerpt.length, content: excerpt }));
|
|
84
|
+
chars += excerpt.length;
|
|
85
|
+
if (chars >= maxChars) break;
|
|
86
|
+
}
|
|
87
|
+
return Object.freeze(rows);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function buildCloudflareCpuAuditPacket(input = {}) {
|
|
91
|
+
const cwd = path.resolve(input.cwd || process.cwd());
|
|
92
|
+
const profile = input.profile ? summarizeCloudflareCpuProfile(input.profile, input) : summarizeCloudflareCpuProfileFile({ ...input, cwd });
|
|
93
|
+
return Object.freeze({
|
|
94
|
+
schema_version: 1,
|
|
95
|
+
primitive: 'cloudflare.cpu.audit',
|
|
96
|
+
rules: Object.freeze({ read_only: true, may_edit: false, may_deploy: false, production_timer_cpu_measurement_valid: false }),
|
|
97
|
+
profile,
|
|
98
|
+
source_evidence: sourceItems(cwd, input.sources || [], Number(input.maxSourceChars || 24_000)),
|
|
99
|
+
questions: Object.freeze([
|
|
100
|
+
'Which frames dominate self CPU time?',
|
|
101
|
+
'Is garbage collection material?',
|
|
102
|
+
'Which source changes are most likely to reduce CPU without changing behavior?',
|
|
103
|
+
'What local production-like request should reproduce the hotspot?',
|
|
104
|
+
'What production metric/log evidence should confirm improvement?',
|
|
105
|
+
]),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export async function runCloudflareCpuAudit(input = {}) {
|
|
110
|
+
if (typeof input.reasoner !== 'function') throw new TypeError('cloudflare.cpu.audit requires an injected reasoner(packet) function');
|
|
111
|
+
const packet = buildCloudflareCpuAuditPacket(input);
|
|
112
|
+
const result = await input.reasoner(structuredClone(packet));
|
|
113
|
+
if (!result || typeof result !== 'object' || Array.isArray(result)) throw new TypeError('cloudflare.cpu.audit reasoner must return an object');
|
|
114
|
+
return Object.freeze({ schema_version: 1, primitive: 'cloudflare.cpu.audit', profile: packet.profile, analysis: result });
|
|
115
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
WRANGLER_NATIVE_COMMANDS,
|
|
3
|
+
WRANGLER_OPERATION_FAMILIES,
|
|
4
|
+
buildWranglerInvocation,
|
|
5
|
+
listWranglerNativeCommands,
|
|
6
|
+
parseWranglerErrorEvidence,
|
|
7
|
+
runWranglerNative,
|
|
8
|
+
} from './wrangler.js';
|
|
9
|
+
export {
|
|
10
|
+
summarizeCloudflareCpuProfile,
|
|
11
|
+
summarizeCloudflareCpuProfileFile,
|
|
12
|
+
buildCloudflareCpuAuditPacket,
|
|
13
|
+
runCloudflareCpuAudit,
|
|
14
|
+
} from './cpu-profile.js';
|