@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Trust, Credentials, and Credentialed Destinations
|
|
2
|
+
|
|
3
|
+
## Trust is about execution ownership
|
|
4
|
+
|
|
5
|
+
The useful distinction is not "frontend equals UI" and "backend equals logic."
|
|
6
|
+
The useful distinction is who controls execution.
|
|
7
|
+
|
|
8
|
+
A browser, mobile client, or other user-controlled runtime can be inspected and
|
|
9
|
+
modified by that user. Treat requests from it as claims that the trusted side must
|
|
10
|
+
validate. Server-owned runtimes can hold privileged credentials and enforce durable
|
|
11
|
+
invariants, but they still must authenticate callers and apply least privilege.
|
|
12
|
+
|
|
13
|
+
## Public identifiers versus credentials
|
|
14
|
+
|
|
15
|
+
A public client/application ID tells a provider **which registered application** is
|
|
16
|
+
participating. It is often visible in redirect URLs or client configuration and is
|
|
17
|
+
not, by itself, proof of authority.
|
|
18
|
+
|
|
19
|
+
A client secret, API key, signing key, refresh token, database credential, or similar
|
|
20
|
+
secret is authority-bearing material. Its value belongs only in the runtime that is
|
|
21
|
+
allowed to use that authority. Do not confuse a secret's environment variable name
|
|
22
|
+
with the secret itself.
|
|
23
|
+
|
|
24
|
+
## OAuth redirect mental model
|
|
25
|
+
|
|
26
|
+
Keep the endpoints separate:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
/app/auth/login
|
|
30
|
+
-> creates state / PKCE material as appropriate
|
|
31
|
+
-> redirects browser to provider authorization endpoint
|
|
32
|
+
|
|
33
|
+
provider
|
|
34
|
+
-> authenticates user + consent
|
|
35
|
+
-> redirects only to registered callback
|
|
36
|
+
|
|
37
|
+
/app/auth/callback
|
|
38
|
+
-> verifies state and flow binding
|
|
39
|
+
-> exchanges code server-to-server when the flow requires it
|
|
40
|
+
-> validates provider identity claims
|
|
41
|
+
-> finds/creates local user
|
|
42
|
+
-> establishes the app's own session
|
|
43
|
+
-> redirects to the intended in-app destination
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The callback is not the user's final product page. It is a security-sensitive
|
|
47
|
+
boundary where the external authorization flow becomes an internal authenticated
|
|
48
|
+
session.
|
|
49
|
+
|
|
50
|
+
For clients that cannot safely keep a static secret, use the provider's supported
|
|
51
|
+
public-client flow such as Authorization Code + PKCE rather than embedding a secret
|
|
52
|
+
in the client.
|
|
53
|
+
|
|
54
|
+
## Destination registry mindset
|
|
55
|
+
|
|
56
|
+
Treat every external system as a typed destination rather than an ad-hoc URL string.
|
|
57
|
+
For each destination record:
|
|
58
|
+
|
|
59
|
+
- canonical provider/service identity;
|
|
60
|
+
- allowed host/origin and transport;
|
|
61
|
+
- caller execution domain;
|
|
62
|
+
- public IDs versus secret credentials;
|
|
63
|
+
- scopes/permissions;
|
|
64
|
+
- redirect/callback/webhook endpoints;
|
|
65
|
+
- input/output schemas;
|
|
66
|
+
- retry, timeout, idempotency, and rate-limit behavior;
|
|
67
|
+
- audit/logging rules that never emit secrets;
|
|
68
|
+
- rotation/revocation owner.
|
|
69
|
+
|
|
70
|
+
This is the mechanism that makes `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, a
|
|
71
|
+
callback URI, and a login route understandable as one relationship instead of four
|
|
72
|
+
unrelated strings.
|
|
73
|
+
|
|
74
|
+
## Defense in depth
|
|
75
|
+
|
|
76
|
+
Think in layers, each assuming the layer before it can fail:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
internet
|
|
80
|
+
-> edge/DDoS protection
|
|
81
|
+
-> firewall/WAF/bot/rate-limit policy
|
|
82
|
+
-> route/authentication
|
|
83
|
+
-> authorization + ownership validation
|
|
84
|
+
-> runtime schema validation
|
|
85
|
+
-> least-privilege credential/service access
|
|
86
|
+
-> durable audit/observability
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
A WAF can reject known-bad traffic, but it cannot know your business ownership rule.
|
|
90
|
+
Authentication can prove a user identity, but it does not automatically prove that
|
|
91
|
+
user may modify a particular record. A valid credential can authenticate a service
|
|
92
|
+
while still being over-privileged. Re-verify at each boundary.
|
|
93
|
+
|
|
94
|
+
## Fail fast at configuration boundaries
|
|
95
|
+
|
|
96
|
+
Validate required runtime configuration when the process/worker starts or before the
|
|
97
|
+
first privileged operation. Check presence, expected public/secret classification,
|
|
98
|
+
allowed destination, and format where the provider defines one. Never log the secret
|
|
99
|
+
value to explain a validation failure.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentsam-cloudflare-workers
|
|
3
|
+
description: >
|
|
4
|
+
Treat Cloudflare Workers, Wrangler, Durable Objects, D1, R2, Queues, Hyperdrive,
|
|
5
|
+
Browser, Containers, observability, versions, and deployment mechanics as a native
|
|
6
|
+
AgentSam execution dialect. Use when inspecting, debugging, profiling, operating,
|
|
7
|
+
or shipping Cloudflare-backed applications. Prefer typed Wrangler operations,
|
|
8
|
+
machine-readable output, explicit risk classes, real error/trace identifiers, and
|
|
9
|
+
Worker-runtime semantics over generic shell guessing.
|
|
10
|
+
metadata:
|
|
11
|
+
short-description: "Cloudflare Workers/Wrangler native operations, observability, errors, and CPU discipline"
|
|
12
|
+
aliases:
|
|
13
|
+
- cloudflare
|
|
14
|
+
- workers
|
|
15
|
+
- wrangler
|
|
16
|
+
- cf-native
|
|
17
|
+
user-invocable: true
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# AgentSam Cloudflare Workers
|
|
21
|
+
|
|
22
|
+
Cloudflare is a first-class execution environment, not just a deploy target. Use its
|
|
23
|
+
runtime rules and Wrangler command contracts as native vocabulary.
|
|
24
|
+
|
|
25
|
+
## Operating laws
|
|
26
|
+
|
|
27
|
+
- Prefer structured Wrangler output such as `whoami --json`, deployments/versions JSON, and JSON tail events where supported.
|
|
28
|
+
- Never ask a model to read or print `wrangler auth token`, API tokens, secrets, cookies, or credential files. Identity status is useful evidence; credential bytes are not.
|
|
29
|
+
- Classify every operation before execution: read, local-runtime, filesystem-write, remote-write, secret-bearing, or long-running stream.
|
|
30
|
+
- Keep `cwd`, account authority, connection identity, and execution leases runtime-owned. Do not accept them from model arguments when they are security-relevant.
|
|
31
|
+
- Preserve real provider/runtime errors: process exit code, HTTP status, machine error type/code, request/Ray IDs, retry metadata, and bounded redacted stderr/body.
|
|
32
|
+
- Do not infer CPU time from `performance.now()` or `Date.now()` around pure computation in a deployed Worker. Production timers advance around I/O; use local workerd/DevTools CPU profiles and production CPU metrics.
|
|
33
|
+
- For expensive CPU investigations, collect a bounded profile summary and selected source evidence first, then hand that packet to the chosen reasoning model. Do not dump the repository or raw multi-megabyte profile into model context.
|
|
34
|
+
- Prefer Web Crypto/native runtime primitives for CPU-intensive cryptography instead of pure-JavaScript reimplementations where the Worker contract allows it.
|
|
35
|
+
- Remember that open TCP sockets have runtime and Durable Object lifecycle/cost implications; close them deliberately and prefer platform-native database connectivity such as Hyperdrive where appropriate.
|
|
36
|
+
|
|
37
|
+
## Native workflow
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
identify worker/config
|
|
41
|
+
-> verify Cloudflare identity without exposing token
|
|
42
|
+
-> inspect deployments/versions/config/types
|
|
43
|
+
-> reproduce locally with wrangler dev/workerd
|
|
44
|
+
-> collect JSON logs / CPU profile / production metrics
|
|
45
|
+
-> normalize errors and trace IDs
|
|
46
|
+
-> select only implicated source evidence
|
|
47
|
+
-> deterministic summary
|
|
48
|
+
-> optional high-reasoning model audit
|
|
49
|
+
-> verify locally
|
|
50
|
+
-> deploy only through the normal progression guard
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Read the references for command risk classes, error envelopes, and CPU/observability mechanics.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Worker CPU profiling
|
|
2
|
+
|
|
3
|
+
A deployed Worker's `performance.now()` and `Date.now()` do not measure pure CPU loops reliably because the clock advances around I/O rather than ordinary CPU execution. Never create fake production CPU timings from those APIs.
|
|
4
|
+
|
|
5
|
+
For CPU work:
|
|
6
|
+
|
|
7
|
+
1. Reproduce with `wrangler dev`/workerd using production-like routes, request volume, and data/bindings where safe.
|
|
8
|
+
2. Open DevTools from the Wrangler session and record a CPU profile.
|
|
9
|
+
3. Export the `.cpuprofile` and run `agentsam cloudflare cpu analyze <profile.cpuprofile>`.
|
|
10
|
+
4. Use the ranked self-time frames to select a small source slice.
|
|
11
|
+
5. Optionally hand the bounded profile + selected source packet to a high-reasoning model through `cloudflare.cpu.audit`.
|
|
12
|
+
6. Verify the fix locally, then compare production CPU metrics/error rate after normal deployment gates.
|
|
13
|
+
|
|
14
|
+
Pay attention to garbage collection as well as application frames. Large allocation churn can be the hotspot even when no single application function looks dominant.
|
|
15
|
+
|
|
16
|
+
Use native implementations when they remove JavaScript CPU work. For example, Worker Web Crypto operations are preferable to CPU-heavy pure-JavaScript cryptography when compatible with the required algorithm and contract.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Cloudflare errors and observability
|
|
2
|
+
|
|
3
|
+
## Error evidence contract
|
|
4
|
+
|
|
5
|
+
When an operation fails, retain the most specific machine evidence available:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
source/provider
|
|
9
|
+
operation
|
|
10
|
+
process exit code or HTTP status
|
|
11
|
+
machine error type
|
|
12
|
+
machine error code
|
|
13
|
+
request id / cf-ray when present
|
|
14
|
+
retry-after and retry classification
|
|
15
|
+
requested vs resolved processing/runtime mode when relevant
|
|
16
|
+
bounded redacted response body or stderr
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Do not flatten this to `request failed`, `429`, `500`, or `Wrangler failed` when richer evidence exists.
|
|
20
|
+
|
|
21
|
+
## Retry discipline
|
|
22
|
+
|
|
23
|
+
Retry only failures that can plausibly recover without changing operator state. Rate limits, ramp-rate throttles, overload, and transient provider 5xx errors may be retryable. Authentication, invalid arguments, billing/spend limits, unsupported regions, and missing permissions require configuration or operator action instead of retry loops.
|
|
24
|
+
|
|
25
|
+
## Worker telemetry
|
|
26
|
+
|
|
27
|
+
Use production Workers metrics/logs/traces for live evidence. Tail Workers and diagnostics channels can carry structured diagnostic events, but observability itself consumes resources and should remain bounded. Prefer structured fields and stable trace/request IDs over giant free-form logs.
|
|
28
|
+
|
|
29
|
+
Unhandled promise rejections are runtime evidence and should be surfaced with the rejection reason/trace while redacting secrets.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Wrangler native map
|
|
2
|
+
|
|
3
|
+
Treat Wrangler commands as typed operations rather than arbitrary shell text.
|
|
4
|
+
|
|
5
|
+
## Safe model-visible reads
|
|
6
|
+
|
|
7
|
+
AgentSam's initial native executor intentionally exposes only:
|
|
8
|
+
|
|
9
|
+
- `whoami --json`
|
|
10
|
+
- `deployments list --json`
|
|
11
|
+
- `versions list --json`
|
|
12
|
+
- `types --check`
|
|
13
|
+
- `queues list`
|
|
14
|
+
|
|
15
|
+
These are argv-built and cwd/config scoped. The allowlist is intentionally smaller than Wrangler's full command surface.
|
|
16
|
+
|
|
17
|
+
## Known operational families
|
|
18
|
+
|
|
19
|
+
- Identity/config: `whoami`, `auth list`, `auth activate`, `login`.
|
|
20
|
+
- Development: `dev`, `types`, local persistence, remote bindings.
|
|
21
|
+
- Observability: `tail`, deployments, versions, logs/traces/metrics.
|
|
22
|
+
- Delivery: `deploy`, version deployment, rollback, triggers.
|
|
23
|
+
- Data: D1, R2, KV, Queues, Hyperdrive, Vectorize.
|
|
24
|
+
- Compute/AI: Containers, Browser, Workers AI, Workflows and related products.
|
|
25
|
+
|
|
26
|
+
Remote mutation, rollback, secret handling, token retrieval, data writes, and long-running streams require a dedicated policy/approval path. Do not broaden the safe executor by passing arbitrary trailing argv.
|
|
27
|
+
|
|
28
|
+
Wrangler global controls such as `--config`, `--cwd`, `--env`, and `--profile` are useful scoping mechanics. Keep them explicit; do not silently switch accounts or environments.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentsam-jr-dev
|
|
3
|
+
description: >
|
|
4
|
+
Teach, inspect, build, and revise software in junior-developer-friendly language
|
|
5
|
+
without replacing real engineering with toy explanations. Use when a user asks
|
|
6
|
+
what code, HTTP, frontend/backend, APIs, databases, auth, services, workers,
|
|
7
|
+
repositories, packages, deployments, or application architecture mean; when
|
|
8
|
+
onboarding someone to an unfamiliar repo; or when explaining why a proposed
|
|
9
|
+
implementation belongs in a particular layer. Also use while building or
|
|
10
|
+
reviewing software when the user benefits from understanding the real mechanics.
|
|
11
|
+
Triggers on "jr dev", "junior dev", "explain this", "what is HTTP", "frontend",
|
|
12
|
+
"backend", "API", "service", "microservice", "how does this app work", "repo map",
|
|
13
|
+
"teach me", "break this down", and "why does this go here".
|
|
14
|
+
metadata:
|
|
15
|
+
short-description: "Teach real software mechanics from the actual repo, then prove the implementation"
|
|
16
|
+
aliases:
|
|
17
|
+
- agentsam_jr_dev
|
|
18
|
+
- jr-dev
|
|
19
|
+
user-invocable: true
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# AgentSam Jr Dev
|
|
23
|
+
|
|
24
|
+
Teach software by connecting **simple mental models to the actual system in front
|
|
25
|
+
of you**. The goal is not to make engineering sound easy. The goal is to make
|
|
26
|
+
real engineering understandable without hiding the mechanics.
|
|
27
|
+
|
|
28
|
+
A successful Jr Dev answer leaves the user knowing:
|
|
29
|
+
|
|
30
|
+
1. **what the thing is,**
|
|
31
|
+
2. **why it exists,**
|
|
32
|
+
3. **where it lives in this project,**
|
|
33
|
+
4. **what talks to it,**
|
|
34
|
+
5. **what state or authority it owns,** and
|
|
35
|
+
6. **how to prove it works.**
|
|
36
|
+
|
|
37
|
+
Do not teach a fake generic architecture when repository evidence is available.
|
|
38
|
+
Inspect first, then explain what is actually there.
|
|
39
|
+
|
|
40
|
+
## Core behavior
|
|
41
|
+
|
|
42
|
+
### 1. Start with the smallest useful explanation
|
|
43
|
+
|
|
44
|
+
Use this progression unless the user asks for a different depth:
|
|
45
|
+
|
|
46
|
+
- **10-second model** — one plain-language sentence.
|
|
47
|
+
- **mechanics** — the actual request/data/control flow.
|
|
48
|
+
- **repo proof** — name the real files, directories, routes, schemas, or services.
|
|
49
|
+
- **engineering consequence** — explain why the boundary matters when building or changing it.
|
|
50
|
+
|
|
51
|
+
Example:
|
|
52
|
+
|
|
53
|
+
> HTTP is the agreed request/response language two programs use to talk over a
|
|
54
|
+
> network. In this repo, the browser calls `/api/models`; the backend route
|
|
55
|
+
> receives that request, uses trusted server-side configuration, and returns a
|
|
56
|
+
> response the frontend can render.
|
|
57
|
+
|
|
58
|
+
Never stop at an analogy when the user needs the real mechanism.
|
|
59
|
+
|
|
60
|
+
### 2. Inspect before teaching repo-specific facts
|
|
61
|
+
|
|
62
|
+
For an unfamiliar project, establish the system shape before making claims:
|
|
63
|
+
|
|
64
|
+
- project/package manifests,
|
|
65
|
+
- top-level tree,
|
|
66
|
+
- runtime entrypoints,
|
|
67
|
+
- frontend entrypoint and routes,
|
|
68
|
+
- backend/server/worker entrypoint,
|
|
69
|
+
- shared contracts,
|
|
70
|
+
- API/transport boundaries,
|
|
71
|
+
- persistence/storage,
|
|
72
|
+
- auth/identity,
|
|
73
|
+
- environment/config,
|
|
74
|
+
- tests,
|
|
75
|
+
- deployment/runtime configuration.
|
|
76
|
+
|
|
77
|
+
Prefer deterministic repository/index/search tools over reading giant trees or
|
|
78
|
+
hundreds of files into context. Read the smallest relevant spans that prove the
|
|
79
|
+
explanation.
|
|
80
|
+
|
|
81
|
+
### 3. Teach boundaries as ownership
|
|
82
|
+
|
|
83
|
+
When explaining architecture, answer **who owns what**:
|
|
84
|
+
|
|
85
|
+
- frontend owns presentation and browser interaction,
|
|
86
|
+
- backend owns trusted execution and privileged access,
|
|
87
|
+
- shared/contracts own the shape both sides agree on,
|
|
88
|
+
- database/storage owns durable state,
|
|
89
|
+
- auth owns verified identity,
|
|
90
|
+
- HTTP/RPC/WebSocket is transport, not business logic,
|
|
91
|
+
- workers/servers are runtime entrypoints, not automatically the whole backend,
|
|
92
|
+
- packages expose reusable capabilities,
|
|
93
|
+
- apps compose those capabilities into complete products,
|
|
94
|
+
- services are independently running capabilities with explicit interfaces.
|
|
95
|
+
|
|
96
|
+
Do not teach folder names as universal laws. A repo may call these layers
|
|
97
|
+
`client/server`, `web/api`, `ui/core`, `worker`, or something else. Explain the
|
|
98
|
+
**responsibility** first, then map it to this repo's names.
|
|
99
|
+
|
|
100
|
+
Read `references/web-application-fundamentals.md` for the canonical beginner
|
|
101
|
+
mental models and request-flow examples.
|
|
102
|
+
|
|
103
|
+
### 4. Real application logic is the standard
|
|
104
|
+
|
|
105
|
+
A polished screen is not proof of a working application. For any build/revision,
|
|
106
|
+
trace the behavior end-to-end:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
user intent
|
|
110
|
+
-> UI/input
|
|
111
|
+
-> validated action/request
|
|
112
|
+
-> trusted business logic
|
|
113
|
+
-> state/storage/provider side effect
|
|
114
|
+
-> response/event
|
|
115
|
+
-> UI state update
|
|
116
|
+
-> verification
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
If the requested feature crosses layers, implement and verify every required
|
|
120
|
+
layer. Do not hide missing backend/storage/auth/integration work behind mocked
|
|
121
|
+
frontend state unless the user explicitly asked for a prototype.
|
|
122
|
+
|
|
123
|
+
Read `references/real-application-logic.md` before claiming a new application,
|
|
124
|
+
service, or cross-layer feature is complete.
|
|
125
|
+
|
|
126
|
+
### 5. Explain changes in terms of consequences
|
|
127
|
+
|
|
128
|
+
Instead of:
|
|
129
|
+
|
|
130
|
+
> I moved this into the backend because that's cleaner.
|
|
131
|
+
|
|
132
|
+
Prefer:
|
|
133
|
+
|
|
134
|
+
> This operation needs a secret and writes durable state, so the browser cannot
|
|
135
|
+
> be its authority. The frontend sends the user's intent; the backend verifies
|
|
136
|
+
> it and performs the write. That keeps the secret off the client and gives us
|
|
137
|
+
> one trusted place to enforce validation.
|
|
138
|
+
|
|
139
|
+
Teach *why*, not just style conventions.
|
|
140
|
+
|
|
141
|
+
## No-bullshit rules
|
|
142
|
+
|
|
143
|
+
1. **Never invent a repo architecture.** Inspect it.
|
|
144
|
+
2. **Never call a mock or static screen a finished application** unless the user asked for a mock/prototype.
|
|
145
|
+
3. **Never claim an API/database/service works without exercising its real path** when tools allow verification.
|
|
146
|
+
4. **Never add auth, a database, queues, microservices, or cloud infrastructure just to look production-grade.** Add them when the behavior requires them.
|
|
147
|
+
5. **Never dump huge framework vocabulary before the user has a mental model.** Introduce terms when they explain a real observed mechanism.
|
|
148
|
+
6. **Never equate HTTP with "the backend."** HTTP is one transport. The backend is the trusted logic/runtime behind the interface.
|
|
149
|
+
7. **Never equate a Worker/server file with all business logic.** Prefer thin runtime adapters and explicit application/domain modules when the project warrants it.
|
|
150
|
+
8. **Never teach frontend/backend as a security boundary without checking deployment reality.** Server-side code, browser bundles, secrets, and trust must be verified from the actual framework/runtime.
|
|
151
|
+
9. **Never replace evidence with confidence.** Point to the file, route, schema, test, command, or result that proves the statement.
|
|
152
|
+
10. **Never make "junior" mean patronizing.** Use plain language while preserving the real technical model.
|
|
153
|
+
|
|
154
|
+
## Repo explanation template
|
|
155
|
+
|
|
156
|
+
When someone asks "how does this repo/app work?", prefer a compact map like:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
Product
|
|
160
|
+
what a user can do
|
|
161
|
+
|
|
162
|
+
Frontend
|
|
163
|
+
entrypoint:
|
|
164
|
+
routes/views:
|
|
165
|
+
state:
|
|
166
|
+
calls out to:
|
|
167
|
+
|
|
168
|
+
Backend
|
|
169
|
+
runtime entrypoint:
|
|
170
|
+
API/actions:
|
|
171
|
+
trusted integrations:
|
|
172
|
+
|
|
173
|
+
Shared contracts
|
|
174
|
+
types/schemas/events:
|
|
175
|
+
|
|
176
|
+
State
|
|
177
|
+
browser-local:
|
|
178
|
+
durable database/storage:
|
|
179
|
+
|
|
180
|
+
External systems
|
|
181
|
+
model providers / Git / payments / etc.:
|
|
182
|
+
|
|
183
|
+
Request flow
|
|
184
|
+
user -> frontend -> transport -> backend -> state/provider -> response -> UI
|
|
185
|
+
|
|
186
|
+
Proof
|
|
187
|
+
tests / health checks / real execution path:
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Only include sections the actual project has.
|
|
191
|
+
|
|
192
|
+
## Build/revision workflow
|
|
193
|
+
|
|
194
|
+
For a real task:
|
|
195
|
+
|
|
196
|
+
1. Restate the user-visible behavior in one sentence.
|
|
197
|
+
2. Identify current architecture from repository evidence.
|
|
198
|
+
3. Identify the authority/state owner for the behavior.
|
|
199
|
+
4. Trace the end-to-end flow before editing.
|
|
200
|
+
5. Reuse existing project patterns/contracts where sound.
|
|
201
|
+
6. Make the smallest coherent cross-layer change.
|
|
202
|
+
7. Exercise the real path.
|
|
203
|
+
8. Explain the result at the user's requested depth.
|
|
204
|
+
|
|
205
|
+
When debugging, teach the failing boundary:
|
|
206
|
+
|
|
207
|
+
```text
|
|
208
|
+
input -> frontend -> transport -> backend -> dependency -> persistence -> response
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Find the first point where expected and actual behavior diverge.
|
|
212
|
+
|
|
213
|
+
## Teaching vocabulary
|
|
214
|
+
|
|
215
|
+
Prefer plain term -> precise term:
|
|
216
|
+
|
|
217
|
+
- "the browser screen" -> frontend/client
|
|
218
|
+
- "the trusted code doing the work" -> backend/server
|
|
219
|
+
- "the agreed message shape" -> contract/schema
|
|
220
|
+
- "the request language" -> HTTP
|
|
221
|
+
- "a named HTTP endpoint" -> API route/endpoint
|
|
222
|
+
- "long-lived two-way connection" -> WebSocket
|
|
223
|
+
- "saved state" -> persistence/database/storage
|
|
224
|
+
- "proof of who the user is" -> authentication
|
|
225
|
+
- "what that user is allowed to do" -> authorization
|
|
226
|
+
- "a separately running capability" -> service
|
|
227
|
+
- "a small independently deployed service" -> microservice, only when it actually is one
|
|
228
|
+
- "the program's starting door" -> entrypoint
|
|
229
|
+
- "code reused by multiple products" -> package/library
|
|
230
|
+
|
|
231
|
+
Introduce the precise term immediately after the plain one so the user learns the
|
|
232
|
+
real vocabulary rather than remaining dependent on analogies.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Real Application Logic — Build/Inspection Gate
|
|
2
|
+
|
|
3
|
+
Use this checklist when AgentSam builds, inspects, or revises an application,
|
|
4
|
+
website with behavior, service, microservice, CLI, or cross-layer feature.
|
|
5
|
+
|
|
6
|
+
The purpose is to distinguish a real implementation from a convincing-looking
|
|
7
|
+
surface.
|
|
8
|
+
|
|
9
|
+
## 1. State the behavior
|
|
10
|
+
|
|
11
|
+
Write one sentence describing what a user/system can now actually do.
|
|
12
|
+
|
|
13
|
+
Bad:
|
|
14
|
+
|
|
15
|
+
> Add an agent dashboard.
|
|
16
|
+
|
|
17
|
+
Better:
|
|
18
|
+
|
|
19
|
+
> A signed-in user can start an agent run, watch its live task state, cancel it,
|
|
20
|
+
> and reopen its persisted result later.
|
|
21
|
+
|
|
22
|
+
That sentence exposes the required mechanics.
|
|
23
|
+
|
|
24
|
+
## 2. Find the current architecture
|
|
25
|
+
|
|
26
|
+
Prove where these concerns live today:
|
|
27
|
+
|
|
28
|
+
- entrypoint,
|
|
29
|
+
- UI/client,
|
|
30
|
+
- API/action boundary,
|
|
31
|
+
- business/domain logic,
|
|
32
|
+
- persistence,
|
|
33
|
+
- identity/auth,
|
|
34
|
+
- background work,
|
|
35
|
+
- external providers,
|
|
36
|
+
- tests,
|
|
37
|
+
- deployment/runtime.
|
|
38
|
+
|
|
39
|
+
Do not create a second architecture because the first one took effort to find.
|
|
40
|
+
|
|
41
|
+
## 3. Identify authority
|
|
42
|
+
|
|
43
|
+
For every important state value, ask:
|
|
44
|
+
|
|
45
|
+
> Who is allowed to declare this true?
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
|
|
49
|
+
- `isMenuOpen` -> frontend UI state,
|
|
50
|
+
- `currentUserId` -> verified backend identity,
|
|
51
|
+
- `paymentSucceeded` -> payment provider/backend webhook,
|
|
52
|
+
- `agentRun.status` -> agent runtime/store,
|
|
53
|
+
- `deployment.version` -> deployment system,
|
|
54
|
+
- `file root hash` -> Merkle computation/evidence store.
|
|
55
|
+
|
|
56
|
+
Many broken applications are authority bugs disguised as UI bugs.
|
|
57
|
+
|
|
58
|
+
## 4. Trace the complete flow
|
|
59
|
+
|
|
60
|
+
For mutations:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
intent
|
|
64
|
+
-> input
|
|
65
|
+
-> validation
|
|
66
|
+
-> authorization
|
|
67
|
+
-> business rule
|
|
68
|
+
-> mutation/provider operation
|
|
69
|
+
-> persistence/event
|
|
70
|
+
-> response
|
|
71
|
+
-> visible state
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For reads:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
question/view
|
|
78
|
+
-> query/request
|
|
79
|
+
-> authorization/scope
|
|
80
|
+
-> authoritative source
|
|
81
|
+
-> bounded result
|
|
82
|
+
-> transformation
|
|
83
|
+
-> presentation
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Mark every missing edge before coding.
|
|
87
|
+
|
|
88
|
+
## 5. Handle non-happy paths
|
|
89
|
+
|
|
90
|
+
At minimum consider:
|
|
91
|
+
|
|
92
|
+
- invalid input,
|
|
93
|
+
- unauthenticated/unauthorized request,
|
|
94
|
+
- missing resource,
|
|
95
|
+
- provider/network failure,
|
|
96
|
+
- timeout/cancellation,
|
|
97
|
+
- duplicate/retried request,
|
|
98
|
+
- partial failure,
|
|
99
|
+
- stale client state,
|
|
100
|
+
- empty/loading state.
|
|
101
|
+
|
|
102
|
+
Do not add elaborate machinery for impossible cases, but do not pretend the
|
|
103
|
+
happy path is the whole application either.
|
|
104
|
+
|
|
105
|
+
## 6. Verify reality
|
|
106
|
+
|
|
107
|
+
Prefer the strongest available proof:
|
|
108
|
+
|
|
109
|
+
1. real end-to-end path,
|
|
110
|
+
2. integration test against real local dependency,
|
|
111
|
+
3. contract/API test,
|
|
112
|
+
4. unit test,
|
|
113
|
+
5. static/type/lint check.
|
|
114
|
+
|
|
115
|
+
A screenshot proves appearance. It does not prove persistence, authorization,
|
|
116
|
+
API correctness, side effects, cancellation, or recovery.
|
|
117
|
+
|
|
118
|
+
## 7. Inspect/revision questions
|
|
119
|
+
|
|
120
|
+
When auditing an existing project, ask:
|
|
121
|
+
|
|
122
|
+
- Is there more than one source of truth for the same state?
|
|
123
|
+
- Does frontend code hold secrets or claim authority it should not have?
|
|
124
|
+
- Does the backend trust client-supplied identity/ownership fields?
|
|
125
|
+
- Are runtime entrypoints overloaded with business logic?
|
|
126
|
+
- Are shared packages actually portable, or importing host-specific internals?
|
|
127
|
+
- Are API contracts explicit and validated?
|
|
128
|
+
- Are writes idempotent where retries can occur?
|
|
129
|
+
- Are errors observable and actionable?
|
|
130
|
+
- Are generated/demo/reference files being mistaken for runtime authority?
|
|
131
|
+
- Does the deployment path match the development path closely enough to trust?
|
|
132
|
+
- Can an agent retrieve the exact evidence it needs without flooding context?
|
|
133
|
+
|
|
134
|
+
## 8. Junior explanation after implementation
|
|
135
|
+
|
|
136
|
+
When reporting back, explain in this order:
|
|
137
|
+
|
|
138
|
+
```text
|
|
139
|
+
What changed
|
|
140
|
+
user-visible behavior
|
|
141
|
+
|
|
142
|
+
How it works
|
|
143
|
+
3-7 step real flow
|
|
144
|
+
|
|
145
|
+
Where it lives
|
|
146
|
+
exact important files/modules
|
|
147
|
+
|
|
148
|
+
Why the boundaries are there
|
|
149
|
+
authority/security/state reasons
|
|
150
|
+
|
|
151
|
+
How we proved it
|
|
152
|
+
tests/commands/real runtime evidence
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Keep implementation detail proportional to the user's curiosity, but never hide
|
|
156
|
+
an unimplemented layer behind simplified language.
|