forgeos 0.1.0-alpha.1 → 0.1.0-alpha.10
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/AGENTS.md +38 -3
- package/CHANGELOG.md +94 -0
- package/README.md +72 -12
- package/adapters/go/README.md +23 -0
- package/adapters/go/go.mod +3 -0
- package/adapters/go/http.go +149 -0
- package/adapters/go/registry.go +234 -0
- package/adapters/go/types.go +136 -0
- package/bin/forge.mjs +4 -3
- package/docs/changelog.md +116 -0
- package/docs/forge-protocol.md +156 -0
- package/examples/go-billing/go.mod +7 -0
- package/examples/go-billing/main.go +120 -0
- package/package.json +16 -7
- package/schemas/forge-manifest.schema.json +57 -0
- package/src/forge/_generated/actionSubscriptions.json +1 -2
- package/src/forge/_generated/actionSubscriptions.ts +3 -3
- package/src/forge/_generated/agentAdapterManifest.json +1 -2
- package/src/forge/_generated/agentAdapterManifest.ts +3 -3
- package/src/forge/_generated/agentContract.json +1 -2
- package/src/forge/_generated/agentContract.ts +186 -50
- package/src/forge/_generated/agentQuickstart.md +3 -1
- package/src/forge/_generated/agentTools.json +1 -0
- package/src/forge/_generated/agentTools.md +16 -0
- package/src/forge/_generated/agentTools.ts +12 -0
- package/src/forge/_generated/aiContext.ts +67 -1
- package/src/forge/_generated/aiModels.json +1 -2
- package/src/forge/_generated/aiModels.ts +17 -1
- package/src/forge/_generated/aiProviders.json +0 -1
- package/src/forge/_generated/aiProviders.ts +1 -1
- package/src/forge/_generated/aiRegistry.json +1 -2
- package/src/forge/_generated/aiRegistry.ts +7 -5
- package/src/forge/_generated/api.json +1 -2
- package/src/forge/_generated/api.ts +7 -2
- package/src/forge/_generated/appGraph.json +1 -2
- package/src/forge/_generated/appGraph.ts +1325 -641
- package/src/forge/_generated/appMap.md +21 -1
- package/src/forge/_generated/artifactManifest.json +1 -2
- package/src/forge/_generated/artifactManifest.ts +2 -2
- package/src/forge/_generated/authClaims.json +0 -1
- package/src/forge/_generated/authClaims.ts +1 -1
- package/src/forge/_generated/authConfig.json +0 -1
- package/src/forge/_generated/authConfig.ts +1 -1
- package/src/forge/_generated/authContext.ts +1 -1
- package/src/forge/_generated/authRegistry.json +0 -1
- package/src/forge/_generated/authRegistry.ts +1 -1
- package/src/forge/_generated/buildInfo.json +1 -2
- package/src/forge/_generated/buildInfo.ts +4 -4
- package/src/forge/_generated/capabilityMap.json +1 -2
- package/src/forge/_generated/capabilityMap.md +1 -1
- package/src/forge/_generated/capabilityMap.ts +2 -2
- package/src/forge/_generated/client.ts +88 -1
- package/src/forge/_generated/clientApi.ts +2 -1
- package/src/forge/_generated/clientManifest.json +1 -2
- package/src/forge/_generated/clientManifest.ts +6 -4
- package/src/forge/_generated/clientTypes.ts +19 -1
- package/src/forge/_generated/configRegistry.json +0 -1
- package/src/forge/_generated/configRegistry.ts +1 -1
- package/src/forge/_generated/dataGraph.json +1 -2
- package/src/forge/_generated/dataGraph.ts +3 -3
- package/src/forge/_generated/db.json +0 -1
- package/src/forge/_generated/db.ts +1 -1
- package/src/forge/_generated/dbSecurityManifest.json +0 -1
- package/src/forge/_generated/dbSecurityManifest.ts +1 -1
- package/src/forge/_generated/dbSessionContext.json +0 -1
- package/src/forge/_generated/dbSessionContext.ts +1 -1
- package/src/forge/_generated/deployManifest.json +1 -2
- package/src/forge/_generated/deployManifest.ts +7 -7
- package/src/forge/_generated/devManifest.json +1 -2
- package/src/forge/_generated/devManifest.ts +18 -3
- package/src/forge/_generated/envSchema.json +0 -1
- package/src/forge/_generated/envSchema.ts +1 -1
- package/src/forge/_generated/externalServices.json +1 -0
- package/src/forge/_generated/externalServices.ts +9 -0
- package/src/forge/_generated/frontendGraph.json +0 -1
- package/src/forge/_generated/frontendGraph.ts +1 -1
- package/src/forge/_generated/importGuards.json +0 -1
- package/src/forge/_generated/importGuards.ts +1 -1
- package/src/forge/_generated/index.ts +3 -1
- package/src/forge/_generated/liveProductionManifest.json +0 -1
- package/src/forge/_generated/liveProductionManifest.ts +1 -1
- package/src/forge/_generated/liveProtocol.json +0 -1
- package/src/forge/_generated/liveProtocol.ts +1 -1
- package/src/forge/_generated/liveQueryRegistry.json +1 -2
- package/src/forge/_generated/liveQueryRegistry.ts +3 -3
- package/src/forge/_generated/liveTransportConfig.json +0 -1
- package/src/forge/_generated/liveTransportConfig.ts +1 -1
- package/src/forge/_generated/makeRegistry.json +1 -2
- package/src/forge/_generated/makeRegistry.ts +16 -2
- package/src/forge/_generated/makeTemplates.json +1 -2
- package/src/forge/_generated/makeTemplates.ts +6 -1
- package/src/forge/_generated/mockMap.json +0 -1
- package/src/forge/_generated/mockMap.ts +1 -1
- package/src/forge/_generated/operationPlaybooks.md +34 -14
- package/src/forge/_generated/packageGraph.json +1 -2
- package/src/forge/_generated/packageGraph.ts +8808 -4723
- package/src/forge/_generated/packageUpgradeRegistry.json +1 -2
- package/src/forge/_generated/packageUpgradeRegistry.ts +2 -2
- package/src/forge/_generated/permissionMatrix.json +1 -2
- package/src/forge/_generated/permissionMatrix.ts +3 -3
- package/src/forge/_generated/policyRegistry.json +1 -2
- package/src/forge/_generated/policyRegistry.ts +3 -3
- package/src/forge/_generated/queryRegistry.json +1 -2
- package/src/forge/_generated/queryRegistry.ts +3 -3
- package/src/forge/_generated/react.d.ts +1 -1
- package/src/forge/_generated/react.ts +1 -1
- package/src/forge/_generated/reactManifest.json +1 -2
- package/src/forge/_generated/reactManifest.ts +3 -3
- package/src/forge/_generated/releaseManifest.json +1 -2
- package/src/forge/_generated/releaseManifest.ts +3 -3
- package/src/forge/_generated/rlsPolicies.json +0 -1
- package/src/forge/_generated/rlsPolicies.sql +1 -1
- package/src/forge/_generated/rlsPolicies.ts +1 -1
- package/src/forge/_generated/runtimeGraph.json +1 -2
- package/src/forge/_generated/runtimeGraph.ts +3 -3
- package/src/forge/_generated/runtimeMatrix.json +1 -2
- package/src/forge/_generated/runtimeMatrix.ts +8684 -1939
- package/src/forge/_generated/runtimeRegistry.ts +1 -1
- package/src/forge/_generated/runtimeRules.md +13 -1
- package/src/forge/_generated/secretRegistry.json +0 -1
- package/src/forge/_generated/secretRegistry.ts +1 -1
- package/src/forge/_generated/secretsContext.ts +1 -1
- package/src/forge/_generated/serverApi.ts +2 -1
- package/src/forge/_generated/sourceMapManifest.json +1 -2
- package/src/forge/_generated/sourceMapManifest.ts +2 -2
- package/src/forge/_generated/sqlPlan.json +0 -1
- package/src/forge/_generated/sqlPlan.ts +1 -1
- package/src/forge/_generated/subscriptionManifest.json +1 -2
- package/src/forge/_generated/subscriptionManifest.ts +3 -3
- package/src/forge/_generated/symbolicationManifest.json +1 -2
- package/src/forge/_generated/symbolicationManifest.ts +2 -2
- package/src/forge/_generated/telemetryRegistry.json +1 -2
- package/src/forge/_generated/telemetryRegistry.ts +3 -3
- package/src/forge/_generated/telemetrySinks.json +1 -2
- package/src/forge/_generated/telemetrySinks.ts +2 -2
- package/src/forge/_generated/tenantScope.json +1 -2
- package/src/forge/_generated/tenantScope.ts +3 -3
- package/src/forge/_generated/testGraph.json +1 -2
- package/src/forge/_generated/testGraph.ts +465 -13
- package/src/forge/_generated/testPlanRegistry.json +1 -2
- package/src/forge/_generated/testPlanRegistry.ts +2 -2
- package/src/forge/_generated/uiRoutes.json +0 -1
- package/src/forge/_generated/uiRoutes.ts +1 -1
- package/src/forge/_generated/uiScenarios.json +0 -1
- package/src/forge/_generated/uiScenarios.ts +1 -1
- package/src/forge/_generated/uiTestManifest.json +1 -2
- package/src/forge/_generated/uiTestManifest.ts +2 -2
- package/src/forge/_generated/workflowRegistry.json +1 -2
- package/src/forge/_generated/workflowRegistry.ts +3 -3
- package/src/forge/_generated/workflowSubscriptions.json +1 -2
- package/src/forge/_generated/workflowSubscriptions.ts +3 -3
- package/src/forge/bench.ts +248 -0
- package/src/forge/cli/ai.ts +671 -3
- package/src/forge/cli/auth.ts +36 -1
- package/src/forge/cli/build.ts +1 -1
- package/src/forge/cli/commands.ts +152 -0
- package/src/forge/cli/dev.ts +32 -5
- package/src/forge/cli/main.ts +3 -1
- package/src/forge/cli/new.ts +29 -1
- package/src/forge/cli/parse.ts +194 -10
- package/src/forge/cli/query.ts +32 -0
- package/src/forge/cli/rls.ts +568 -17
- package/src/forge/cli/run.ts +41 -0
- package/src/forge/cli/secrets.ts +46 -1
- package/src/forge/cli/security.ts +381 -0
- package/src/forge/cli/verify.ts +201 -24
- package/src/forge/compiler/agent-contract/build.ts +407 -12
- package/src/forge/compiler/agent-contract/types.ts +72 -0
- package/src/forge/compiler/ai-registry/build.ts +62 -1
- package/src/forge/compiler/ai-registry/constants.ts +1 -1
- package/src/forge/compiler/ai-registry/parse.ts +98 -4
- package/src/forge/compiler/api-surface/build.ts +47 -0
- package/src/forge/compiler/app-graph/build.ts +33 -5
- package/src/forge/compiler/app-graph/forge-apis.ts +1 -0
- package/src/forge/compiler/app-graph/module-graph.ts +73 -78
- package/src/forge/compiler/app-graph/parser.ts +24 -24
- package/src/forge/compiler/app-graph/profile.ts +26 -0
- package/src/forge/compiler/classifier/capabilities.ts +3 -2
- package/src/forge/compiler/classifier/classify.ts +32 -8
- package/src/forge/compiler/classifier/secrets.ts +3 -2
- package/src/forge/compiler/classifier/signals.ts +91 -1
- package/src/forge/compiler/client-sdk/build-manifest.ts +4 -0
- package/src/forge/compiler/client-sdk/render-client.ts +105 -0
- package/src/forge/compiler/dev-manifest/build.ts +3 -0
- package/src/forge/compiler/diagnostics/codes.ts +27 -0
- package/src/forge/compiler/diagnostics/create.ts +1 -1
- package/src/forge/compiler/emitter/render.ts +5 -0
- package/src/forge/compiler/external-manifest/registry.ts +204 -0
- package/src/forge/compiler/external-manifest/types.ts +89 -0
- package/src/forge/compiler/external-manifest/validate.ts +335 -0
- package/src/forge/compiler/make-registry/build.ts +13 -0
- package/src/forge/compiler/orchestrator/plan-profile.ts +23 -0
- package/src/forge/compiler/orchestrator/plan.ts +63 -11
- package/src/forge/compiler/orchestrator/profile.ts +65 -0
- package/src/forge/compiler/orchestrator/run.ts +97 -31
- package/src/forge/compiler/orchestrator/serialize.ts +81 -6
- package/src/forge/compiler/package-graph/compiler.ts +13 -3
- package/src/forge/compiler/policy-registry/build.ts +44 -1
- package/src/forge/compiler/test-graph/build.ts +11 -3
- package/src/forge/compiler/types/ai-registry.ts +25 -1
- package/src/forge/compiler/types/app-graph.ts +1 -0
- package/src/forge/compiler/types/cli.ts +4 -0
- package/src/forge/compiler/types/dev-manifest.ts +3 -0
- package/src/forge/dev/server.ts +592 -3
- package/src/forge/make/index.ts +126 -3
- package/src/forge/make/templates.ts +190 -2
- package/src/forge/make/types.ts +1 -0
- package/src/forge/runtime/ai/context.ts +210 -5
- package/src/forge/runtime/ai/types.ts +70 -0
- package/src/forge/runtime/auth/claims.ts +32 -0
- package/src/forge/runtime/auth/errors.ts +2 -0
- package/src/forge/runtime/context/create-context.ts +30 -6
- package/src/forge/runtime/db/memory-adapter.ts +2 -2
- package/src/forge/runtime/db/postgres-adapter.ts +6 -3
- package/src/forge/runtime/executor.ts +3 -2
- package/src/forge/runtime/external/bridge.ts +553 -0
- package/src/forge/runtime/live/live-query-runner.ts +2 -1
- package/src/forge/runtime/outbox/process.ts +2 -1
- package/src/forge/runtime/query/run-query.ts +2 -1
- package/src/forge/runtime/runner/run-entry.ts +2 -1
- package/src/forge/runtime/telemetry/scrubber.ts +56 -5
- package/src/forge/runtime/telemetry/sinks/posthog.ts +4 -5
- package/src/forge/runtime/telemetry/sinks/sentry.ts +4 -5
- package/src/forge/runtime/webhooks/security.ts +184 -0
- package/src/forge/runtime/workflows/resolve-step.ts +2 -1
- package/src/forge/server.ts +93 -0
- package/src/forge/version.ts +1 -1
- package/templates/b2b-support-web/package.json +2 -0
- package/templates/b2b-support-web/src/actions/captureTicketCreated.ts +7 -2
- package/templates/b2b-support-web/src/commands/closeTicket.ts +6 -1
- package/templates/b2b-support-web/src/commands/createTicket.ts +8 -2
- package/templates/b2b-support-web/src/queries/getTicket.ts +8 -1
- package/templates/b2b-support-web/tsconfig.json +4 -1
- package/templates/b2b-support-web/web/components/CreateTicketForm.tsx +1 -2
- package/templates/b2b-support-web/web/components/PolicyDeniedDemo.tsx +1 -2
- package/templates/b2b-support-web/web/components/TicketList.tsx +1 -2
- package/templates/b2b-support-web/web/components/TraceDetails.tsx +1 -1
- package/templates/b2b-support-web/web/lib/forge.ts +1 -0
- package/templates/b2b-support-web/web/package.json +1 -1
- package/templates/minimal-web/package.json +2 -1
- package/templates/minimal-web/tsconfig.json +3 -1
- package/templates/minimal-web/web/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @forge-generated generator=0.1.0-alpha.
|
|
1
|
+
// @forge-generated generator=0.1.0-alpha.10 input=9b218d51e45bbb3220f861cec8dcd08f63224475d6356fc73d26c330ddf108e7 content=1611635edf59c122b013ba76c85bd333ab3b30b289aaea04a9074f9438782a50
|
|
2
2
|
# AGENTS.md
|
|
3
3
|
|
|
4
4
|
<!-- forge-generated:start -->
|
|
@@ -69,6 +69,7 @@ forge inspect app --json
|
|
|
69
69
|
forge inspect all --json
|
|
70
70
|
forge inspect frontend --json
|
|
71
71
|
forge inspect capabilities --json
|
|
72
|
+
forge inspect agent-tools --json
|
|
72
73
|
forge deps inspect <package> --json
|
|
73
74
|
forge deps api <package> <symbol> --json
|
|
74
75
|
forge deps trace <package> --json
|
|
@@ -82,6 +83,9 @@ forge doctor
|
|
|
82
83
|
forge doctor windows --json
|
|
83
84
|
forge setup windows --json
|
|
84
85
|
forge agent print-context --json
|
|
86
|
+
forge ai tools --json
|
|
87
|
+
forge ai agents --json
|
|
88
|
+
forge ai trace <traceId> --json
|
|
85
89
|
forge verify --smoke
|
|
86
90
|
forge verify --standard
|
|
87
91
|
forge verify --strict
|
|
@@ -103,6 +107,21 @@ Tenant-scoped tables:
|
|
|
103
107
|
- ANTHROPIC_API_KEY (required)
|
|
104
108
|
- OPENAI_API_KEY (required)
|
|
105
109
|
|
|
110
|
+
## AI Tools And Agents
|
|
111
|
+
|
|
112
|
+
- AI SDK engine: Vercel AI SDK v6.
|
|
113
|
+
- Forge layer: generated registry, runtime rules, telemetry, secrets, tenant/auth context, and agent contract.
|
|
114
|
+
- Use `ctx.agent.run` or `ctx.ai.runAgent` only in actions, workflows, endpoints, and server code.
|
|
115
|
+
- Do not create custom tool loops; use Forge tools and AI SDK `ToolLoopAgent` through the Forge runtime.
|
|
116
|
+
|
|
117
|
+
Tools:
|
|
118
|
+
|
|
119
|
+
- none
|
|
120
|
+
|
|
121
|
+
Agents:
|
|
122
|
+
|
|
123
|
+
- none
|
|
124
|
+
|
|
106
125
|
## Auth
|
|
107
126
|
|
|
108
127
|
- Modes: dev-headers, jwt, oidc, disabled
|
|
@@ -158,6 +177,7 @@ Use:
|
|
|
158
177
|
forge make resource <name> --fields title:text,status:enum(open,closed) --dry-run --json
|
|
159
178
|
forge make resource <name> --fields title:text,status:enum(open,closed) --with-ui --yes
|
|
160
179
|
forge make ui --framework vite --dry-run --json
|
|
180
|
+
forge make ai-chat support --dry-run --json
|
|
161
181
|
```
|
|
162
182
|
|
|
163
183
|
Review the plan before applying when the resource touches schema or policies.
|
|
@@ -194,11 +214,13 @@ Use:
|
|
|
194
214
|
```bash
|
|
195
215
|
forge refactor rename field tickets.priority tickets.urgency --dry-run --json
|
|
196
216
|
forge refactor rename field tickets.priority tickets.urgency --yes
|
|
217
|
+
forge refactor rename command createTicket openTicket --dry-run --json
|
|
218
|
+
forge refactor rename command createTicket openTicket --yes
|
|
197
219
|
```
|
|
198
220
|
|
|
199
|
-
These codemods are AST-aware for `extract-action`, `rename field`, and `rename table`. Field renames are scoped to the target table, so `tickets.priority` only rewrites references linked to `tickets`.
|
|
221
|
+
These codemods are AST-aware for `extract-action`, `rename command`, `rename field`, and `rename table`. Command renames update runtime registries, generated client references, frontend hooks, tests, and string references where safe. Field renames are scoped to the target table, so `tickets.priority` only rewrites references linked to `tickets`.
|
|
200
222
|
|
|
201
|
-
Never edit `src/forge/_generated/**` directly. Review migration hints before applying field or table renames.
|
|
223
|
+
Never edit `src/forge/_generated/**` directly. Review migration hints before applying command, field, or table renames.
|
|
202
224
|
|
|
203
225
|
### Plan impact-based tests
|
|
204
226
|
|
|
@@ -224,6 +246,19 @@ forge repair plan --from-last-test-run --write
|
|
|
224
246
|
|
|
225
247
|
Apply only high-confidence deterministic repairs automatically. Review medium or low confidence repairs before changing code.
|
|
226
248
|
|
|
249
|
+
### Add AI tools or agents
|
|
250
|
+
|
|
251
|
+
Use:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
forge generate
|
|
255
|
+
forge inspect all --json
|
|
256
|
+
forge ai check --json
|
|
257
|
+
forge ai trace <traceId> --json
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Define tools with `aiTool({ inputSchema, outputSchema, risk, needsApproval, handler })` and agents with `agent({ provider, model, instructions, tools, stopWhen })`. Execute agents with `ctx.agent.run` or `ctx.ai.runAgent` only from actions, workflows, endpoints, or server code. In dev, POST `/ai/agents/run` returns JSON for automation and POST `/ai/agents/chat` returns an AI SDK UIMessage stream for React `useChat`; both accept `agent: "<exportedAgentName>"` and use generated auto-tools from `agentTools.json`.
|
|
261
|
+
|
|
227
262
|
### Export agent adapters
|
|
228
263
|
|
|
229
264
|
Use:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# forgeos
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.10
|
|
4
|
+
|
|
5
|
+
Launch polish:
|
|
6
|
+
|
|
7
|
+
- Fixed `forge run <external-command> --args ...` so CLI arguments reach the external runtime bridge.
|
|
8
|
+
- Added direct external query CLI support through `forge query <service.query> --args ...`.
|
|
9
|
+
- Emit generated `.json` artifacts as pure JSON while keeping deterministic headers on code/text artifacts.
|
|
10
|
+
- Relaxed the `minimal-web` template verify script to `forge verify --smoke` and added the missing `check` script to `b2b-support-web`.
|
|
11
|
+
- Updated public protocol/changelog docs for the external runtime and Go adapter alpha line.
|
|
12
|
+
- Bumped the create-app wrapper package line to `create-forgeos-app@0.1.0-alpha.4`.
|
|
13
|
+
|
|
14
|
+
## 0.1.0-alpha.9
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Added the Forge external runtime protocol bridge for manifest-backed commands and queries.
|
|
19
|
+
- Added the Go adapter MVP with a real `go-billing` conformance example.
|
|
20
|
+
- Emitted external service metadata into inspect/API/agent artifacts, including `needsApproval` for agent tools.
|
|
21
|
+
- Reuse compiler classifier package signals across export classification, dropping repeated package signal scans.
|
|
22
|
+
- Reuse serialized graph JSON when rendering the largest generated TypeScript graph artifacts.
|
|
23
|
+
- Keep generated Forge artifacts aligned with the `0.1.0-alpha.9` compiler/runtime version.
|
|
24
|
+
|
|
25
|
+
## 0.1.0-alpha.8
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [`7568756`](https://github.com/Stahldavid/forge/commit/756875688873dd60d3d6cf700a7bb7c211968c69) Thanks [@Stahldavid](https://github.com/Stahldavid)! - Publish prerelease packages through the ForgeOS alpha publisher so npm dist-tags stay aligned.
|
|
30
|
+
|
|
31
|
+
## 0.1.0-alpha.7
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- [`4ace311`](https://github.com/Stahldavid/forge/commit/4ace3113e3298b5c306000870922fcfbae9c1861) Thanks [@Stahldavid](https://github.com/Stahldavid)! - Keep npm prerelease publishing on the public alpha dist-tag.
|
|
36
|
+
|
|
37
|
+
## 0.1.0-alpha.6
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- [`c30f906`](https://github.com/Stahldavid/forge/commit/c30f9069c99ac747ce143ab5fbcbf13912ed8760) Thanks [@Stahldavid](https://github.com/Stahldavid)! - Add CLI version output, align create-app help with package metadata, and add release dependency audit evidence.
|
|
42
|
+
|
|
43
|
+
## 0.1.0-alpha.5
|
|
44
|
+
|
|
45
|
+
Release alignment for the public alpha channel:
|
|
46
|
+
|
|
47
|
+
- Added `forge ai redteam --model-level --json` with deterministic prompt-injection, secret-exfiltration, approval-bypass, cross-tenant, and indirect tool-injection probes.
|
|
48
|
+
- Added `forge security prove --full --json` support for source checkouts, with graceful structural-proof fallback when packaged apps do not include ForgeOS test fixtures.
|
|
49
|
+
- Strengthened npm publish workflows to run `security prove --db postgres --full --json`.
|
|
50
|
+
- Added public registry smoke coverage for `forgeos@alpha` and `create-forgeos-app@alpha`.
|
|
51
|
+
- Bumped the create-app wrapper package line to `create-forgeos-app@0.1.0-alpha.1`.
|
|
52
|
+
|
|
53
|
+
## 0.1.0-alpha.4
|
|
54
|
+
|
|
55
|
+
Security assurance and release evidence hardening:
|
|
56
|
+
|
|
57
|
+
- Added value-aware telemetry redaction for known secret values in safe-looking fields, messages, details, outputs, and stack traces.
|
|
58
|
+
- Added webhook signature, timestamp, and replay protection helpers with Stripe/GitHub/generic HMAC coverage.
|
|
59
|
+
- Added HTTP tenant-isolation tests that exercise the dev server/API boundary, not only the internal runtime executor.
|
|
60
|
+
- Added `forge rls mutate-test --json` to kill dangerous generated RLS mutations such as missing FORCE RLS, missing policies, unconditional predicates, and `BYPASSRLS`.
|
|
61
|
+
- Extended `forge security prove --json` with RLS mutation proof and invariant-level evidence metadata.
|
|
62
|
+
- Added scripts to split security evidence by invariant and emit basic release supply-chain evidence plus CycloneDX SBOM.
|
|
63
|
+
- Strengthened publish/security workflows so release gates use Postgres-backed security proof, RLS mutation proof, release evidence, and SBOM generation.
|
|
64
|
+
|
|
65
|
+
## 0.1.0-alpha.3
|
|
66
|
+
|
|
67
|
+
Native Forge AI agents on top of Vercel AI SDK v6:
|
|
68
|
+
|
|
69
|
+
- Added `aiTool` and `agent` primitives with generated `agentTools.json` / `agentTools.md`.
|
|
70
|
+
- Added `ctx.agent.run` and `ctx.ai.runAgent` using AI SDK `ToolLoopAgent`.
|
|
71
|
+
- Added auto-tools for commands, queries, and liveQueries with read-only vs approval-required writes.
|
|
72
|
+
- Added dev agent endpoints: `POST /ai/agents/run` and `POST /ai/agents/chat`.
|
|
73
|
+
- Extended `forge ai` CLI with `tools`, `agents`, and `trace` subcommands.
|
|
74
|
+
- Added `forge inspect agent-tools` and agent tool metadata in `agentContract.json`.
|
|
75
|
+
- Upgraded runtime dependency to AI SDK v6 for tool calling, streaming UI, and MCP compatibility.
|
|
76
|
+
|
|
77
|
+
Documentation:
|
|
78
|
+
|
|
79
|
+
- Added public [AI](https://forgeos.readthedocs.io/en/latest/ai/) page and AST-aware `rename command` codemod docs.
|
|
80
|
+
- Expanded ReadTheDocs to full agent-native coverage: agent workflow (`forge do`), frontend/liveQuery, security/data, authoring, testing/repair, self-host, templates, Material theme, and changelog page.
|
|
81
|
+
|
|
82
|
+
## 0.1.0-alpha.2
|
|
83
|
+
|
|
84
|
+
Windows and generated-app hardening:
|
|
85
|
+
|
|
86
|
+
- Fixed Node ESM handler loading on Windows by importing generated app modules
|
|
87
|
+
through `file://` URLs across commands, queries, liveQueries, outbox actions,
|
|
88
|
+
workflow steps, mocks, and telemetry adapters.
|
|
89
|
+
- Fixed `forge dev` SSE streaming on the Node HTTP fallback so liveQuery
|
|
90
|
+
snapshots are flushed immediately instead of buffering forever.
|
|
91
|
+
- Hardened generated app scaffolding and web dev spawning on Windows.
|
|
92
|
+
- Updated the B2B support template to route frontend imports through
|
|
93
|
+
`web/lib/forge.ts` and use safer handler input validation.
|
|
94
|
+
- Added focused tests for Node compatibility, template scaffolding, runtime
|
|
95
|
+
imports, and streaming responses.
|
|
96
|
+
|
|
3
97
|
## 0.1.0-alpha.1
|
|
4
98
|
|
|
5
99
|
Republish alpha with the dependency/API oracle improvements:
|
package/README.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Agent-native application framework and compiler for building Forge apps without a mandatory dashboard. ForgeOS turns application source into deterministic runtime contracts, generated clients, safety checks, and machine-readable context that humans and AI coding agents can use safely.
|
|
4
4
|
|
|
5
|
-
**Status:** private/public alpha MVP, implemented through
|
|
5
|
+
**Status:** private/public alpha MVP, implemented through H43. ForgeOS already includes the compiler, local runtime, frontend SDK, production auth, RLS compiler, liveQuery, self-host artifacts, generated agent contract, guided dev loop, repair/review/test tooling, AST-aware codemods, package intelligence, native AI tools/agents, npm alpha publishing, and Read the Docs public docs. Public release hardening is still focused on deeper semantic codemods, broader field reports, and more production mileage.
|
|
6
6
|
|
|
7
|
-
Public docs
|
|
7
|
+
Public docs live at [forgeos.readthedocs.io](https://forgeos.readthedocs.io/). The repo builds them with `.readthedocs.yaml`, `mkdocs.yml`, and `docs/index.md`.
|
|
8
|
+
|
|
9
|
+
Start with [Why ForgeOS](https://forgeos.readthedocs.io/en/latest/why-forgeos/) to understand the agent-native design.
|
|
8
10
|
|
|
9
11
|
## Agent-First Quickstart
|
|
10
12
|
|
|
@@ -44,6 +46,22 @@ These files describe the app surface, runtime rules, generated files, policies,
|
|
|
44
46
|
|
|
45
47
|
## Create a Test App
|
|
46
48
|
|
|
49
|
+
Public one-command app creation:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm create forgeos-app@alpha notes-app -- --template minimal-web
|
|
53
|
+
cd notes-app
|
|
54
|
+
npm run dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Equivalent lower-level command without installing ForgeOS globally:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm exec --package forgeos@alpha -- forge new notes-app --template minimal-web --package-manager npm
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If ForgeOS is already installed or you are inside this repository:
|
|
64
|
+
|
|
47
65
|
```bash
|
|
48
66
|
forge new notes-app --template minimal-web --package-manager npm
|
|
49
67
|
cd notes-app
|
|
@@ -58,11 +76,11 @@ Templates also include workspace editor excludes for generated/runtime directori
|
|
|
58
76
|
For release or external smoke testing, choose the Forge package source explicitly:
|
|
59
77
|
|
|
60
78
|
```bash
|
|
61
|
-
forge new smoke-app --template minimal-web --package-manager npm --forge-spec "npm:forgeos
|
|
79
|
+
forge new smoke-app --template minimal-web --package-manager npm --forge-spec "npm:forgeos@alpha"
|
|
62
80
|
forge new local-app --template minimal-web --package-manager npm --local-forge
|
|
63
81
|
```
|
|
64
82
|
|
|
65
|
-
`--forge-spec` writes that dependency spec into the generated app, while `--local-forge` keeps the monorepo/local package workflow. The npm package is published as `forgeos`, but generated apps keep the dependency key, CLI binary, and import surface as `forge` (`forge`, `forge/server`, `forge/react`) by using npm alias specs such as `"forge": "npm:forgeos
|
|
83
|
+
`--forge-spec` writes that dependency spec into the generated app, while `--local-forge` keeps the monorepo/local package workflow. The npm package is published as `forgeos`, but generated apps keep the dependency key, CLI binary, and import surface as `forge` (`forge`, `forge/server`, `forge/react`) by using npm alias specs such as `"forge": "npm:forgeos@alpha"`. CI uses both `--forge-spec "file:$GITHUB_WORKSPACE"` and a packed tarball smoke to prove freshly created apps can install ForgeOS and run outside the framework workspace.
|
|
66
84
|
|
|
67
85
|
For broader field testing:
|
|
68
86
|
|
|
@@ -73,6 +91,35 @@ npm run field:test -- --package-managers npm --templates minimal-web --forge-spe
|
|
|
73
91
|
|
|
74
92
|
The scheduled/manual `Field Tests` workflow expands that coverage across Linux, macOS, Windows, Node 22, Node 24, and npm/pnpm/yarn/bun.
|
|
75
93
|
|
|
94
|
+
## External Runtimes And Go Adapter
|
|
95
|
+
|
|
96
|
+
ForgeOS can import services written outside TypeScript through the Forge Protocol.
|
|
97
|
+
External runtimes publish a `forge.manifest.json` that describes commands, queries,
|
|
98
|
+
transport, policies, risk metadata, tenant scope, and schemas. Forge then emits
|
|
99
|
+
the same machine-readable app/API/agent artifacts and exposes runtime bridge
|
|
100
|
+
endpoints for those entries.
|
|
101
|
+
|
|
102
|
+
The first adapter MVP is Go:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
cd examples/go-billing
|
|
106
|
+
go run . --manifest --base-url http://127.0.0.1:8787 > forge.manifest.json
|
|
107
|
+
go run . --addr 127.0.0.1:8787 --base-url http://127.0.0.1:8787
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
In a Forge app:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
forge manifest validate ./forge.manifest.json --json
|
|
114
|
+
forge manifest import ./forge.manifest.json --json
|
|
115
|
+
forge generate
|
|
116
|
+
forge run billing.createInvoice --args '{"title":"Invoice"}' --user-id u1 --tenant-id tenant-a --role admin
|
|
117
|
+
forge query billing.listInvoices --args '{}' --user-id u1 --tenant-id tenant-a --role admin
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
See [`docs/forge-protocol.md`](docs/forge-protocol.md), [`schemas/forge-manifest.schema.json`](schemas/forge-manifest.schema.json),
|
|
121
|
+
and [`adapters/go`](adapters/go/README.md).
|
|
122
|
+
|
|
76
123
|
## What ForgeOS Generates
|
|
77
124
|
|
|
78
125
|
```txt
|
|
@@ -122,7 +169,7 @@ forge.lock
|
|
|
122
169
|
| Auth | dev headers, JWT, OIDC discovery/JWKS verification via `jose`, production-mode guardrails |
|
|
123
170
|
| RLS | Postgres RLS SQL compiler/checks for DB-enforced tenant isolation |
|
|
124
171
|
| Secrets/env | secret registry, env schema, redaction, strict `process.env` checks |
|
|
125
|
-
| AI | provider registry, `ctx.ai`, mock mode, telemetry without prompt/output retention by default |
|
|
172
|
+
| AI | Vercel AI SDK v6 engine, provider registry, `ctx.ai`, `ctx.agent.run`, `aiTool`, `agent`, `/ai/agents/run` JSON automation, `/ai/agents/chat` UIMessage streaming, `forge ai trace`, structural and model-level redteam probes, mock mode, telemetry without prompt/output retention by default |
|
|
126
173
|
| Frontend | generated client SDK, React/Next hooks, template app, liveQuery client support |
|
|
127
174
|
| LiveQuery | durable invalidation log, reconnect/resume semantics, production hardening checks |
|
|
128
175
|
| Self-host | compose/deploy artifacts and self-host checks |
|
|
@@ -198,6 +245,7 @@ Common command groups:
|
|
|
198
245
|
Refactor codemods are AST-aware where safety matters most:
|
|
199
246
|
|
|
200
247
|
- `forge refactor extract-action` is binding-aware and preserves unrelated imports, type-only imports, and shadowed locals.
|
|
248
|
+
- `forge refactor rename command <oldName> <newName>` rewrites command declarations, generated client references, React hook usage, tests, and safe string references while preserving unrelated symbols.
|
|
201
249
|
- `forge refactor rename field <table.field> <table.field>` rewrites structured TS/JS/JSX/TSX and JSON references, preserves locals, and scopes the field change to files/objects linked to the target table. For example, `tickets.priority -> tickets.urgency` does not rewrite a generic `priority` prop in a component with no `tickets` binding.
|
|
202
250
|
- `forge refactor rename table <from> <to>` rewrites table definitions, `ctx.db.<table>` access, policy strings, JSON/blueprints, and import/export specifiers while preserving unrelated locals with the same name.
|
|
203
251
|
|
|
@@ -226,12 +274,23 @@ See [`examples/showcase-forge-app`](examples/showcase-forge-app/README.md).
|
|
|
226
274
|
|
|
227
275
|
```bash
|
|
228
276
|
cd examples/showcase-forge-app
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
277
|
+
npm install
|
|
278
|
+
npm run generate
|
|
279
|
+
npm run dev
|
|
232
280
|
```
|
|
233
281
|
|
|
234
|
-
|
|
282
|
+
For the reproducible public proof path:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npm run proof:inspect
|
|
286
|
+
npm run proof:dev
|
|
287
|
+
npm run proof:capabilities
|
|
288
|
+
npm run proof:verify
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Read [`examples/showcase-forge-app/PUBLIC_PROOF.md`](examples/showcase-forge-app/PUBLIC_PROOF.md) for the full walkthrough.
|
|
292
|
+
|
|
293
|
+
Examples are source-only where practical: generated artifacts, `forge.lock`, package lockfiles, and operational `.forge/**` state are recreated locally. The showcase demonstrates tenant-scoped data, policies, commands, queries, liveQueries, outbox actions, workflows, mock AI, telemetry trace IDs, generated React hooks, `agentContract`, `frontendGraph`, `capabilityMap`, and the standard agent handoff loop.
|
|
235
294
|
|
|
236
295
|
## Platform Support
|
|
237
296
|
|
|
@@ -307,7 +366,7 @@ For the first prerelease publish, use the alpha dist-tag explicitly:
|
|
|
307
366
|
|
|
308
367
|
```bash
|
|
309
368
|
npm run release:publish-local-alpha -- --dry-run
|
|
310
|
-
npm run release:publish-
|
|
369
|
+
npm run release:publish-alpha
|
|
311
370
|
```
|
|
312
371
|
|
|
313
372
|
The normal path is:
|
|
@@ -330,7 +389,7 @@ Configure npm Trusted Publisher for package `forgeos`:
|
|
|
330
389
|
| Environment | blank |
|
|
331
390
|
| Allowed action | `npm publish` |
|
|
332
391
|
|
|
333
|
-
Do not add `NPM_TOKEN` for normal releases. Alpha releases publish with the `alpha` dist-tag so prerelease builds do not become `latest` accidentally.
|
|
392
|
+
Do not add `NPM_TOKEN` for normal releases. Alpha releases publish with the `alpha` dist-tag so prerelease builds do not become `latest` accidentally. Use `release:publish-local-alpha -- --dry-run` only to validate the staged tarball locally; real npm publishing should go through `release:publish-alpha`, which dispatches `publish.yml` and uses npm OIDC Trusted Publisher. The workflow checks whether the package version already exists before installing dependencies or running tests, then uses `id-token: write`, Node 24/npm 11+, and provenance for the actual publish. `npm run release:smoke` runs `npm pack`, creates a fresh app with the packed tarball, installs dependencies, runs `forge dev --once --json`, and verifies the app smoke path.
|
|
334
393
|
|
|
335
394
|
## Milestone History
|
|
336
395
|
|
|
@@ -377,11 +436,12 @@ H39 Showcase app
|
|
|
377
436
|
H40 Windows/runtime hardening
|
|
378
437
|
H41 Node-compatible CLI/runtime
|
|
379
438
|
H42 Verify observability and quieter app workspaces
|
|
439
|
+
H43 Native AI tools and agent loop
|
|
380
440
|
```
|
|
381
441
|
|
|
382
442
|
## Remaining Hardening Before Public Release
|
|
383
443
|
|
|
384
|
-
- Keep expanding semantic codemods beyond the current AST-aware `extract-action`, `rename field`, and `rename table` paths.
|
|
444
|
+
- Keep expanding semantic codemods beyond the current AST-aware `extract-action`, `rename command`, `rename field`, and `rename table` paths.
|
|
385
445
|
- Reduce command-selection risk with more task routers and richer inline diagnostics.
|
|
386
446
|
- Keep hardening native Windows setup beyond diagnostics and safe automatic environment fixes.
|
|
387
447
|
- Keep broadening package manager CI from template smoke toward install/build smoke for pnpm and yarn apps.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Forge Go Adapter
|
|
2
|
+
|
|
3
|
+
`adapters/go` is the minimal Go SDK for external Forge runtimes. It registers
|
|
4
|
+
commands and queries, emits `forge.manifest.json`, and exposes a Forge-compatible
|
|
5
|
+
HTTP handler.
|
|
6
|
+
|
|
7
|
+
```go
|
|
8
|
+
app := forge.New("billing", forge.BaseURL("http://127.0.0.1:8787"))
|
|
9
|
+
|
|
10
|
+
app.Command("createInvoice", forge.Handle(createInvoice),
|
|
11
|
+
forge.Policy("billing.manage"),
|
|
12
|
+
forge.TenantScoped(true),
|
|
13
|
+
forge.NeedsApproval(true),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
app.Query("listInvoices", forge.Handle(listInvoices),
|
|
17
|
+
forge.Policy("billing.manage"),
|
|
18
|
+
forge.TenantScoped(true),
|
|
19
|
+
)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The HTTP handler accepts Forge runtime envelopes on `/commands/:name` and
|
|
23
|
+
`/queries/:name`, then returns `{ "ok": true, "result": ... }` envelopes.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
package forge
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"errors"
|
|
6
|
+
"net/http"
|
|
7
|
+
"strings"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
func (registry *Registry) HTTPHandler() http.Handler {
|
|
11
|
+
mux := http.NewServeMux()
|
|
12
|
+
mux.HandleFunc(registry.service.Health, registry.handleHealth)
|
|
13
|
+
mux.HandleFunc("/manifest", registry.handleManifest)
|
|
14
|
+
mux.HandleFunc("/commands/", registry.handleRuntime(KindCommand, "/commands/"))
|
|
15
|
+
mux.HandleFunc("/queries/", registry.handleRuntime(KindQuery, "/queries/"))
|
|
16
|
+
return mux
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func (registry *Registry) handleHealth(response http.ResponseWriter, request *http.Request) {
|
|
20
|
+
writeJSON(response, http.StatusOK, map[string]any{
|
|
21
|
+
"ok": true,
|
|
22
|
+
"service": registry.service.Name,
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func (registry *Registry) handleManifest(response http.ResponseWriter, request *http.Request) {
|
|
27
|
+
baseURL := request.URL.Query().Get("baseUrl")
|
|
28
|
+
if baseURL == "" {
|
|
29
|
+
baseURL = registry.service.BaseURL
|
|
30
|
+
}
|
|
31
|
+
writeJSON(response, http.StatusOK, registry.Manifest(baseURL))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func (registry *Registry) handleRuntime(kind EntryKind, prefix string) http.HandlerFunc {
|
|
35
|
+
return func(response http.ResponseWriter, request *http.Request) {
|
|
36
|
+
name := strings.TrimPrefix(request.URL.Path, prefix)
|
|
37
|
+
registered, ok := registry.lookup[lookupKey(kind, name)]
|
|
38
|
+
if !ok {
|
|
39
|
+
writeError(response, http.StatusNotFound, "", "FORGE_GO_ENTRY_NOT_FOUND", "external entry not found")
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
if request.Method != http.MethodPost && request.Method != http.MethodGet {
|
|
43
|
+
writeError(response, http.StatusMethodNotAllowed, "", "FORGE_GO_METHOD_NOT_ALLOWED", "external entry only accepts GET or POST")
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
envelope, err := readRequestEnvelope(request)
|
|
48
|
+
traceID := traceIDFrom(request, envelope)
|
|
49
|
+
if err != nil {
|
|
50
|
+
writeError(response, http.StatusBadRequest, traceID, "FORGE_GO_BAD_REQUEST", err.Error())
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
if envelope.Forge.Service == "" {
|
|
54
|
+
envelope.Forge.Service = registry.service.Name
|
|
55
|
+
}
|
|
56
|
+
if envelope.Forge.Entry == "" {
|
|
57
|
+
envelope.Forge.Entry = name
|
|
58
|
+
}
|
|
59
|
+
if envelope.Forge.Kind == "" {
|
|
60
|
+
envelope.Forge.Kind = string(kind)
|
|
61
|
+
}
|
|
62
|
+
if envelope.Forge.TraceID == "" {
|
|
63
|
+
envelope.Forge.TraceID = traceID
|
|
64
|
+
}
|
|
65
|
+
if envelope.Auth.Kind == "" {
|
|
66
|
+
envelope.Auth = authFromHeaders(request.Header)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
call := &Context{
|
|
70
|
+
Auth: envelope.Auth,
|
|
71
|
+
Forge: envelope.Forge,
|
|
72
|
+
Headers: request.Header,
|
|
73
|
+
}
|
|
74
|
+
result, err := registered.handler(request.Context(), call, envelope.Args)
|
|
75
|
+
if err != nil {
|
|
76
|
+
writeError(response, http.StatusInternalServerError, envelope.Forge.TraceID, "FORGE_GO_HANDLER_FAILED", err.Error())
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
writeJSON(response, http.StatusOK, ResponseEnvelope{
|
|
80
|
+
OK: true,
|
|
81
|
+
Result: result,
|
|
82
|
+
TraceID: envelope.Forge.TraceID,
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
func readRequestEnvelope(request *http.Request) (RequestEnvelope, error) {
|
|
88
|
+
if request.Method == http.MethodGet {
|
|
89
|
+
args := request.URL.Query().Get("args")
|
|
90
|
+
if args == "" {
|
|
91
|
+
args = "{}"
|
|
92
|
+
}
|
|
93
|
+
return RequestEnvelope{Args: json.RawMessage(args)}, nil
|
|
94
|
+
}
|
|
95
|
+
defer request.Body.Close()
|
|
96
|
+
var envelope RequestEnvelope
|
|
97
|
+
decoder := json.NewDecoder(request.Body)
|
|
98
|
+
if err := decoder.Decode(&envelope); err != nil {
|
|
99
|
+
return envelope, err
|
|
100
|
+
}
|
|
101
|
+
if len(envelope.Args) == 0 {
|
|
102
|
+
envelope.Args = json.RawMessage("{}")
|
|
103
|
+
}
|
|
104
|
+
if !json.Valid(envelope.Args) {
|
|
105
|
+
return envelope, errors.New("request args must be valid JSON")
|
|
106
|
+
}
|
|
107
|
+
return envelope, nil
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
func authFromHeaders(headers http.Header) Auth {
|
|
111
|
+
auth := Auth{Kind: headers.Get("x-forge-auth-kind")}
|
|
112
|
+
if auth.Kind == "" {
|
|
113
|
+
auth.Kind = "anonymous"
|
|
114
|
+
}
|
|
115
|
+
auth.UserID = headers.Get("x-forge-user-id")
|
|
116
|
+
auth.TenantID = headers.Get("x-forge-tenant-id")
|
|
117
|
+
auth.Role = headers.Get("x-forge-role")
|
|
118
|
+
return auth
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
func traceIDFrom(request *http.Request, envelope RequestEnvelope) string {
|
|
122
|
+
if envelope.Forge.TraceID != "" {
|
|
123
|
+
return envelope.Forge.TraceID
|
|
124
|
+
}
|
|
125
|
+
return request.Header.Get("x-forge-trace-id")
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
func writeError(response http.ResponseWriter, status int, traceID string, code string, message string) {
|
|
129
|
+
writeJSON(response, status, ResponseEnvelope{
|
|
130
|
+
OK: false,
|
|
131
|
+
Diagnostics: []Diagnostic{{
|
|
132
|
+
Severity: "error",
|
|
133
|
+
Code: code,
|
|
134
|
+
Message: message,
|
|
135
|
+
Docs: []string{"docs/forge-protocol.md"},
|
|
136
|
+
}},
|
|
137
|
+
Error: &ErrorInfo{
|
|
138
|
+
Code: code,
|
|
139
|
+
Message: message,
|
|
140
|
+
},
|
|
141
|
+
TraceID: traceID,
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
func writeJSON(response http.ResponseWriter, status int, body any) {
|
|
146
|
+
response.Header().Set("content-type", "application/json")
|
|
147
|
+
response.WriteHeader(status)
|
|
148
|
+
_ = json.NewEncoder(response).Encode(body)
|
|
149
|
+
}
|