@m-kopa/launchpad-cli 0.73.0 → 0.74.1

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.
@@ -0,0 +1,8 @@
1
+ import type { CliConfig } from "../config.js";
2
+ import type { CliIo, ExitCode } from "../dispatcher.js";
3
+ import type { AdminCommandDeps } from "./admin.js";
4
+ /** Lowercase hex SHA-256 of the full key string, prefix included. */
5
+ export declare function integrationKeyHash(key: string): string;
6
+ export declare function runAdminIntegrations(args: readonly string[], io: CliIo, config: CliConfig, deps: AdminCommandDeps): Promise<ExitCode>;
7
+ export declare function printIntegrationsUsage(print: (line: string) => void): void;
8
+ //# sourceMappingURL=admin-integrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-integrations.d.ts","sourceRoot":"","sources":["../../src/commands/admin-integrations.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAwBnD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,KAAK,EACT,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,QAAQ,CAAC,CAenB;AAuHD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAG1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,UAAU,EAEX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAS,OAAO,EAAY,MAAM,kBAAkB,CAAC;AAMjE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,UAAU,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,OAAO,CAAC;CAClC;AAID,eAAO,MAAM,YAAY,EAAE,OAA4B,CAAC;AAExD,wBAAgB,gBAAgB,CAC9B,IAAI,GAAE,gBAA4B,GACjC,OAAO,CAMT"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,UAAU,EAEX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAS,OAAO,EAAY,MAAM,kBAAkB,CAAC;AAOjE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,UAAU,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,OAAO,CAAC;CAClC;AAID,eAAO,MAAM,YAAY,EAAE,OAA4B,CAAC;AAExD,wBAAgB,gBAAgB,CAC9B,IAAI,GAAE,gBAA4B,GACjC,OAAO,CAMT"}
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AA0EA,OAAO,EAGL,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAiB/B,OAAO,EAAa,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAY,MAAM,kBAAkB,CAAC;AAUjE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAC;AAEjD,eAAO,MAAM,aAAa,EAAE,OAI3B,CAAC;AAEF,UAAU,UAAU;IAClB,6BAA6B;IAC7B,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,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;CACrD,GAAG,OAAO,CAIV;AAED,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,OAAO,EACvB,UAAU,GAAE,OAAO,GAAG,SAAqB,GAC1C,MAAM,CAOR"}
@@ -5,7 +5,7 @@ import type { Command } from "../dispatcher.js";
5
5
  * "bundled list matches the skills dir" test in `tests/skills-command.test.ts`
6
6
  * enforces this so a newly-added skill dir can't silently go un-installed.
7
7
  */
8
- export declare const BUNDLED_SKILLS: readonly ["launchpad-onboard", "launchpad-deploy", "launchpad-deploy-status", "launchpad-content-pr", "launchpad-status", "launchpad-destroy", "launchpad-identity", "launchpad-report", "marquee-share"];
8
+ export declare const BUNDLED_SKILLS: readonly ["launchpad-onboard", "launchpad-deploy", "launchpad-deploy-status", "launchpad-content-pr", "launchpad-status", "launchpad-destroy", "launchpad-identity", "launchpad-ingest", "launchpad-report", "marquee-share"];
9
9
  export declare const skillsCommand: Command;
10
10
  interface InstallEnv {
11
11
  readonly bundleDir: string;
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/commands/skills.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAS,OAAO,EAAY,MAAM,kBAAkB,CAAC;AASjE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,2MAcjB,CAAC;AAcX,eAAO,MAAM,aAAa,EAAE,OAK3B,CAAC;AA2CF,UAAU,UAAU;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,CAQ9C"}
1
+ {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/commands/skills.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAS,OAAO,EAAY,MAAM,kBAAkB,CAAC;AASjE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,+NAejB,CAAC;AAcX,eAAO,MAAM,aAAa,EAAE,OAK3B,CAAC;AA2CF,UAAU,UAAU;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,CAQ9C"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Approved integrations (ADR 0060): print the per-integration status the bot
3
+ * attaches to a deploy response. Informational only; it never changes the
4
+ * deploy's exit code. The body is network input, so names are re-checked
5
+ * against the manifest name rule before they reach the terminal.
6
+ */
7
+ import type { CliIo } from "./dispatcher.js";
8
+ /** The lines to print for the bot's `integrations` field. Empty when absent. */
9
+ export declare function integrationStatusLines(raw: unknown): string[];
10
+ export declare function renderIntegrationStatus(raw: unknown, io: CliIo): void;
11
+ //# sourceMappingURL=integration-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-status.d.ts","sourceRoot":"","sources":["../src/integration-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,gFAAgF;AAChF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,EAAE,CAU7D;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAG,IAAI,CAErE"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.73.0";
1
+ export declare const CLI_VERSION = "0.74.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m-kopa/launchpad-cli",
3
- "version": "0.73.0",
3
+ "version": "0.74.1",
4
4
  "description": "Launchpad CLI — clone / deploy / review / merge against Launchpad-managed apps. Talks to the portal-bot endpoints (SCOPE-M-760 / T4).",
5
5
  "type": "module",
6
6
  "bin": {
package/skills/README.md CHANGED
@@ -16,6 +16,7 @@ skills/
16
16
  ├── launchpad-status/SKILL.md
17
17
  ├── launchpad-destroy/SKILL.md
18
18
  ├── launchpad-identity/SKILL.md # dev / how-to-build skill (see below)
19
+ ├── launchpad-ingest/SKILL.md # dev skill: verified ingest for approved integrations
19
20
  └── marquee-share/ # vendored from M-KOPA/marquee, do
20
21
  # not hand-edit — managed by
21
22
  # scripts/sync-marquee-share-skill.sh
@@ -45,7 +46,9 @@ convention for this kind:
45
46
  `@m-kopa/platform-auth` + the verified example), so it can't fork into a
46
47
  divergent copy.
47
48
 
48
- The next dev-skill should follow this shape.
49
+ `launchpad-ingest` follows it: its handler is extracted from the SKILL.md and
50
+ run by `tests/skill-ingest-extraction.test.ts`, so the code an author copies is
51
+ the code that was tested.
49
52
 
50
53
  ## Cross-platform shell contract
51
54
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-content-pr
3
3
  description: Push a content change to a Launchpad app via `launchpad deploy` and verify it shipped via `launchpad status`. Covers the post-first-deploy iteration loop (edit → deploy → verify) - subsequent deploys commit directly to the app repo's main, then the dispatch delivery (or, for a legacy Pages app, the Pages build) runs asynchronously, so verification is its own step. Use when someone says "push a content change", "ship an update", "/launchpad-content-pr", "verify my deploy", or after `/launchpad-deploy` reports `done` and they want to follow up with an edit.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-deploy
3
3
  description: Walk a Launchpad user through deploying an app from their local working directory (Model A — `launchpad init` + `launchpad deploy`). Wraps the CLI verbs end-to-end: detects the app shape, scaffolds `launchpad.yaml`, resolves the allowed Entra group via `launchpad groups`, bundles the CWD via `launchpad deploy`, and watches the rollout via `launchpad status`. Use when someone says "deploy a new app", "ship my app to Launchpad", "/launchpad-deploy", "I have an app locally — get it on Launchpad", or any variant. Resume/abandon for legacy in-flight provisioning is at the bottom.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-deploy-status
3
3
  description: Show the current provisioning stage + failure reason for a Launchpad app via `launchpad status` (Model A drift + deployment_verified) and `launchpad apps` (lifecycle bucket), or watch provisioning live with `launchpad watch`. Renders the M-892 stage trace for in-flight provisioning, and is the canonical home for `launchpad recover` (repair a terminal-failed app record that is actually live). Use when someone says "what's the status of demo-X", "/launchpad-deploy-status", "is my deploy stuck", "watch my deploy go live", "watch provisioning", "my app says failed but it's serving", or after `/launchpad-deploy` reports a non-`done` terminal stage.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-destroy
3
3
  description: Tear down a Launchpad app end-to-end via `launchpad destroy` — Cloudflare Pages project, edge-auth wiring (gateway KV/audience entries, or the Access app for `auth: access` apps), custom hostname, platform-repo TF, and the app repo (archive-renamed). Owner-only verb with a two-step destructive confirmation. Use when someone says "destroy this app", "/launchpad-destroy", "tear down `<slug>`", "delete the app", or asks to clean up a smoke-test / orphan / retired app.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-identity
3
3
  description: Teach an app author how to use the signed-in user's identity inside a Launchpad app - read the gateway-forwarded X-Launchpad-User-Assertion in the app's server code (functions/ on a react+api app, compiled into its Worker on dispatch, or a Pages Function on a legacy Pages app), VERIFY it with @m-kopa/platform-auth (fail-closed), and show who's logged in (sub/email/name). Use when someone says "who is logged in", "show the current user", "get the user's email in my app", "auth in my launchpad app", "read the user identity", "/launchpad-identity", or is wiring up an /api/me for a gateway-fronted app.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -0,0 +1,288 @@
1
+ ---
2
+ name: launchpad-ingest
3
+ description: Scaffold a verified ingest endpoint so an approved backend (an approved integration, ADR 0060) can write into a Launchpad react+api app - declare the integration in launchpad.yaml, add a Hono route registered ahead of the user-auth middleware that verifies the gateway's X-Launchpad-Integration-Assertion with @m-kopa/platform-auth, validates the body with zod, and does an idempotent D1 insert keyed on a caller-supplied idempotency key. Use when someone says "let another system push data into my app", "add an ingest endpoint", "receive data from the Sales backend", "approved integration", "machine-to-machine write", "/launchpad-ingest", or asks what a calling team must send.
4
+ version: 0.74.1
5
+ ---
6
+
7
+ <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
8
+ ## Shell contract — read this first
9
+
10
+ Every fenced `bash` block below MUST be sent to the `Bash` tool **verbatim**.
11
+ Do not rewrite into PowerShell, cmd, zsh-isms, or "equivalent" forms.
12
+
13
+ - macOS / Linux: the `Bash` tool runs system bash.
14
+ - Windows: the `Bash` tool runs Git for Windows (MSYS) bash. `$HOME`,
15
+ forward slashes, `test -f`, `command -v`, heredocs, and `[[ … ]]` all
16
+ work. There is no reason to translate to `Test-Path`, `$env:USERPROFILE`,
17
+ `Get-Content`, `Where-Object`, `Get-ChildItem`, or backslash paths —
18
+ doing so will fail with `/usr/bin/bash: syntax error`.
19
+
20
+ If a step genuinely needs OS branching, branch *inside* bash:
21
+
22
+ ```bash
23
+ case "$(uname -s)" in
24
+ Darwin) : ;;
25
+ Linux) : ;;
26
+ MINGW*|MSYS*|CYGWIN*) : ;;
27
+ esac
28
+ ```
29
+ <!-- END shell-contract -->
30
+
31
+ # /launchpad-ingest
32
+
33
+ How an app author lets an approved backend write into a Launchpad app, the right way: the gateway checks the caller's key, your handler verifies the gateway's signed assertion, and every write is idempotent.
34
+
35
+ This is a **how-to-build** skill.
36
+ It writes app code; the only CLI verb it runs is `launchpad deploy`.
37
+
38
+ ## What you get, in one sentence
39
+
40
+ A backend sends `Authorization: Bearer lpi_...` to one exact route on your app; the gateway checks the key against the platform-approved list, strips it, and forwards a short-lived RS256 assertion in `X-Launchpad-Integration-Assertion`, which your handler verifies before it writes anything.
41
+
42
+ ## Prerequisites
43
+
44
+ - A **`react+api`** app (dispatch or legacy Pages) with a `functions/api/[[path]].ts` Hono router, as the template scaffolds.
45
+ Static and react apps cannot run server code; see `/launchpad-identity` § Prerequisite for how to get one.
46
+ - A D1 binding named `DB` (`spec.bindings.d1: DB` on dispatch, `targets: [{ kind: pages, d1_binding: DB }]` on Pages).
47
+ - `@m-kopa/platform-auth` **0.8.0 or later** (that release adds `verifyIntegrationAssertion`) and `zod` in the app's `package.json`.
48
+ - A platform admin to approve the integration.
49
+ You can't approve your own; the manifest only asks.
50
+
51
+ ## Step 1 - declare the integration
52
+
53
+ Add it to `launchpad.yaml`.
54
+ The path is an **exact match**: no prefixes, query strings, `%` escapes or trailing `/`.
55
+ Methods are a subset of `POST`, `PUT`, `PATCH`, `DELETE`.
56
+
57
+ ```yaml
58
+ integrations:
59
+ - name: sales-backend
60
+ path: /api/ingest/stock-count
61
+ methods: [POST]
62
+ ```
63
+
64
+ ## Step 2 - create the table
65
+
66
+ The idempotency key is the primary key, so a replayed request can never add a second row.
67
+ Add this as a D1 migration (for example `migrations/0001_stock_counts.sql`).
68
+
69
+ <!-- BEGIN ingest-migration (pinned by tests/skill-ingest-extraction.test.ts) -->
70
+ ```sql
71
+ CREATE TABLE IF NOT EXISTS stock_counts (
72
+ idempotency_key TEXT PRIMARY KEY,
73
+ serial TEXT NOT NULL,
74
+ count_month TEXT NOT NULL,
75
+ agent_id TEXT NOT NULL,
76
+ counted_at TEXT NOT NULL,
77
+ received_at TEXT NOT NULL DEFAULT (datetime('now'))
78
+ );
79
+ ```
80
+ <!-- END ingest-migration -->
81
+
82
+ ## Step 3 - the handler
83
+
84
+ Put this in the same file as your router, `functions/api/[[path]].ts`, above the router.
85
+ A Pages app treats every file under `functions/` as a route, so a separate helper file there would become a route of its own.
86
+ Change `INTEGRATION`, the schema and the SQL to fit your data; keep everything else.
87
+
88
+ <!-- BEGIN ingest-handler (pinned by tests/skill-ingest-extraction.test.ts) -->
89
+ ```ts
90
+ import type { Hono } from "hono";
91
+ import { z } from "zod";
92
+ import {
93
+ createJwksCache,
94
+ INTEGRATION_ASSERTION_HEADER_NAME,
95
+ verifyIntegrationAssertion,
96
+ } from "@m-kopa/platform-auth";
97
+
98
+ /** The `name` from launchpad.yaml. A valid assertion for any other integration is refused. */
99
+ const INTEGRATION = "sales-backend";
100
+
101
+ interface IngestEnv {
102
+ readonly DB: D1Database;
103
+ // The platform sets these. Read both name sets; older Pages apps only carry the CF_ACCESS_* ones.
104
+ readonly GATEWAY_ISSUER?: string;
105
+ readonly GATEWAY_AUD?: string;
106
+ readonly GATEWAY_JWKS_URL?: string;
107
+ readonly CF_ACCESS_TEAM_DOMAIN?: string;
108
+ readonly CF_ACCESS_AUD?: string;
109
+ readonly JWKS_URL?: string;
110
+ }
111
+
112
+ const StockCount = z
113
+ .object({
114
+ idempotency_key: z.string().min(8).max(128),
115
+ serial: z.string().min(1).max(64),
116
+ count_month: z.string().regex(/^\d{4}-\d{2}$/),
117
+ agent_id: z.string().min(1).max(64),
118
+ counted_at: z.string().datetime(),
119
+ })
120
+ .strict();
121
+
122
+ let jwks: ReturnType<typeof createJwksCache> | null = null;
123
+ let jwksUrl: string | null = null;
124
+ function jwksFor(url: string): ReturnType<typeof createJwksCache> {
125
+ if (jwks === null || jwksUrl !== url) {
126
+ jwks = createJwksCache(url);
127
+ jwksUrl = url;
128
+ }
129
+ return jwks;
130
+ }
131
+
132
+ /** Issuer, host and JWKS URL from the platform's env, or null when unset.
133
+ * The host comes from GATEWAY_AUD, never from the request URL: on a Pages
134
+ * origin the request arrives addressed to <project>.pages.dev. */
135
+ function integrationConfig(env: IngestEnv): { issuer: string; host: string; jwksUrl: string } | null {
136
+ const issuer = env.GATEWAY_ISSUER || env.CF_ACCESS_TEAM_DOMAIN;
137
+ const host = env.GATEWAY_AUD || env.CF_ACCESS_AUD;
138
+ if (!issuer || !host) return null;
139
+ const jwksUrl = env.GATEWAY_JWKS_URL || env.JWKS_URL || `${issuer.replace(/\/$/, "")}/.well-known/jwks.json`;
140
+ return { issuer, host, jwksUrl };
141
+ }
142
+
143
+ /** The verified integration name, or null. Forged, expired, wrong host, wrong
144
+ * route, or a user/CLI token all fail closed. */
145
+ async function verifiedIntegration(
146
+ req: Request,
147
+ config: { issuer: string; host: string; jwksUrl: string },
148
+ ): Promise<string | null> {
149
+ const token = req.headers.get(INTEGRATION_ASSERTION_HEADER_NAME);
150
+ if (!token) return null;
151
+ try {
152
+ const { name } = await verifyIntegrationAssertion(token, {
153
+ issuer: config.issuer,
154
+ host: config.host,
155
+ method: req.method,
156
+ path: new URL(req.url).pathname,
157
+ jwks: jwksFor(config.jwksUrl),
158
+ });
159
+ return name;
160
+ } catch {
161
+ return null;
162
+ }
163
+ }
164
+
165
+ /** Register BEFORE the user-auth middleware: machine callers have no user session. */
166
+ export function registerIngestRoutes<E extends { Bindings: IngestEnv }>(app: Hono<E>): void {
167
+ app.post("/ingest/stock-count", async (c) => {
168
+ const config = integrationConfig(c.env);
169
+ if (config === null) return c.json({ error: "integration_unconfigured" }, 503);
170
+ const name = await verifiedIntegration(c.req.raw, config);
171
+ if (name === null) return c.json({ error: "unauthorized" }, 401);
172
+ if (name !== INTEGRATION) return c.json({ error: "forbidden" }, 403);
173
+
174
+ const parsed = StockCount.safeParse(await c.req.json().catch(() => null));
175
+ if (!parsed.success) {
176
+ return c.json({ error: "invalid_body", fields: parsed.error.issues.map((i) => i.path.join(".")) }, 400);
177
+ }
178
+ const row = parsed.data;
179
+ const result = await c.env.DB.prepare(
180
+ `INSERT INTO stock_counts (idempotency_key, serial, count_month, agent_id, counted_at)
181
+ VALUES (?, ?, ?, ?, ?)
182
+ ON CONFLICT(idempotency_key) DO NOTHING`,
183
+ )
184
+ .bind(row.idempotency_key, row.serial, row.count_month, row.agent_id, row.counted_at)
185
+ .run();
186
+ // A replay is a success too, so the caller can retry safely.
187
+ return c.json({ ok: true, duplicate: result.meta.changes === 0 });
188
+ });
189
+ }
190
+ ```
191
+ <!-- END ingest-handler -->
192
+
193
+ ## Step 4 - register it ahead of user auth
194
+
195
+ The template's router authenticates every `/api/*` request as a signed-in user.
196
+ A machine caller has no user session, so the ingest route has to be registered **before** that middleware.
197
+ Hono runs handlers in registration order, and the ingest handler always returns a response, so the user-auth middleware never sees the request.
198
+
199
+ <!-- BEGIN ingest-wiring (pinned by tests/skill-ingest-extraction.test.ts) -->
200
+ ```ts
201
+ const app = new Hono<{ Bindings: Env; Variables: PlatformAuthVariables }>().basePath("/api");
202
+
203
+ // Integration routes first. Everything registered after this line is user-only.
204
+ registerIngestRoutes(app);
205
+
206
+ app.use("*", async (c, next) => {
207
+ const middleware = createPlatformAuthMiddleware({
208
+ teamDomain: c.env.CF_ACCESS_TEAM_DOMAIN,
209
+ audience: c.env.CF_ACCESS_AUD,
210
+ jwks: jwks(c.env),
211
+ });
212
+ return middleware(c, next);
213
+ });
214
+ ```
215
+ <!-- END ingest-wiring -->
216
+
217
+ Add `DB` to your `Env` interface so the types line up.
218
+
219
+ ## Step 5 - deploy and get it approved
220
+
221
+ ```bash
222
+ launchpad deploy
223
+ ```
224
+
225
+ Deploy prints `integration sales-backend: pending platform approval` until a platform admin approves it, then `integration sales-backend: approved`.
226
+ Until then the gateway answers every `lpi_` request to your app with `401`.
227
+ Ask the platform team for approval with `/launchpad-report`, naming the app, the integration and the calling team.
228
+ They mint the key and hand it to the calling team directly; you never hold it.
229
+
230
+ ## If you hand-write the verifier
231
+
232
+ Use `verifyIntegrationAssertion`.
233
+ If you genuinely cannot (for example a build-less app with no `package.json`), your verifier must check **all** of these, and fail closed on any miss:
234
+
235
+ | Claim | Must equal |
236
+ |---|---|
237
+ | signature | RS256 against the gateway JWKS (`https://auth.launchpad.m-kopa.us/.well-known/jwks.json`). No other algorithm. |
238
+ | `iss` | `GATEWAY_ISSUER` (`https://auth.launchpad.m-kopa.us`) |
239
+ | `aud` | `"integration:" + GATEWAY_AUD`, for example `integration:wh-count.launchpad.m-kopa.us` |
240
+ | `typ` | `launchpad-integration` |
241
+ | `sub` | starts with `integration:`; the rest is the integration name, which must be yours |
242
+ | `htm` | the request method, upper case |
243
+ | `htu` | the request path, exactly (`new URL(request.url).pathname`) |
244
+ | `exp` / `nbf` | in date, with at most 30 seconds of clock skew |
245
+
246
+ > ⚠️ **Skipping `aud` or `typ` opens your app to every employee.**
247
+ > The gateway signs user assertions and CLI session tokens with the same key and issuer.
248
+ > Most react+api apps run unconfined on a public `*.pages.dev` origin, so anyone with a Launchpad CLI session can send their own token straight there as `X-Launchpad-Integration-Assertion`.
249
+ > A verifier that checks only the signature and issuer accepts it.
250
+ > Checking `htm` and `htu` stops a captured assertion being replayed against another route.
251
+
252
+ ## What the calling team must do
253
+
254
+ Hand the calling team this contract:
255
+
256
+ - **One header.** `Authorization: Bearer <key>` on `POST https://<slug>.launchpad.m-kopa.us/api/ingest/stock-count`, with a JSON body.
257
+ Never send the key anywhere else or log it.
258
+ Store it in their secret store (for example Key Vault), never in chat or tickets.
259
+ - **An idempotency key per record.** A stable value for the logical record (for example `<serial>:<count_month>`), so a retry or replay never double-writes.
260
+ A replay returns `200` with `"duplicate": true`.
261
+ - **Retry with backoff on `429` and `5xx`** (exponential, with jitter, capped).
262
+ The gateway rate-limits each integration and answers `429` above the ceiling.
263
+ - **Never retry other `4xx`.**
264
+ `401` means a wrong, revoked or unapproved key or route; `403` means a wrong integration or a blocked IP; `400` means a bad body.
265
+ Retrying won't fix any of them.
266
+
267
+ ## Checklist before you ship
268
+
269
+ - [ ] `integrations:` declared in `launchpad.yaml` with the exact path the handler serves.
270
+ - [ ] Ingest route registered **before** the user-auth middleware.
271
+ - [ ] `verifyIntegrationAssertion` gets the host from `GATEWAY_AUD` (never the request URL), the request method, and `new URL(c.req.url).pathname`.
272
+ - [ ] The returned name is checked against your integration.
273
+ - [ ] The body is validated before anything is written.
274
+ - [ ] The insert is keyed on the caller's idempotency key with `ON CONFLICT ... DO NOTHING`.
275
+ - [ ] No route reads `Authorization`: the gateway strips the key before your app sees the request.
276
+
277
+ ## Don'ts
278
+
279
+ - Do **not** trust a request because it reached the route: verify the assertion every time.
280
+ - Do **not** accept a user assertion (`X-Launchpad-User-Assertion`) on an ingest route, or an integration assertion on a user route.
281
+ - Do **not** use a path prefix or wildcard: one key opens exactly one route.
282
+ - Do **not** store or log the assertion or any `lpi_` value.
283
+
284
+ ## Related
285
+
286
+ - `/launchpad-identity` - reading the signed-in **user** in the same app.
287
+ - ADR 0060 - the trust model, approval by reviewed PR, and revoke latency.
288
+ - [Manifest reference: integrations](https://get.launchpad.m-kopa.us/manifest/#integrations-machine-callers).
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-onboard
3
3
  description: One-time setup for the Launchpad CLI + Claude Code skill bundle. Verifies the `launchpad` CLI is installed and current, runs `launchpad whoami` to confirm the session is fresh, and checks the bundled skills are installed and in lock-step with the CLI. Idempotent — safe to re-run any time. Use when someone says "set me up for Launchpad", "I just got a new machine and want to use Launchpad", "/launchpad-onboard", or any of the other launchpad-* skills fails on a prereq check.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -40,7 +40,7 @@ This is the **only** skill that mutates the user's machine (it can
40
40
  trigger `launchpad login` and suggest installs). The other skills
41
41
  (`/launchpad-deploy`, `/launchpad-deploy-status`,
42
42
  `/launchpad-content-pr`, `/launchpad-status`, `/launchpad-destroy`,
43
- `/launchpad-identity`) assume the machine is already onboarded and fail
43
+ `/launchpad-identity`, `/launchpad-ingest`) assume the machine is already onboarded and fail
44
44
  loudly if a prereq is missing — pointing back here.
45
45
 
46
46
  After `launchpad clone <slug>`, refresh that same directory with bare
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-report
3
3
  description: File a bug report or feature request to the Launchpad team's tracker from the CLI. Use when someone reports something broken, hits an error in a launchpad command, or wishes a feature existed — e.g. "this is broken", "report a bug", "can you file that", "I wish launchpad could…", "/launchpad-bug", "/launchpad-feature". Always confirm and show exactly what you'll send before filing; never file silently.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: launchpad-status
3
3
  description: Safely refresh a Launchpad clone, show manifest drift, or read the deployed manifest. Wraps bare `launchpad pull` for source sync, `launchpad pull --manifest` for deployed YAML, and `launchpad status` for drift. Use for "sync my clone", "what's deployed", "show drift", "/launchpad-status", "/launchpad-pull", or post-deploy verification.
4
- version: 0.73.0
4
+ version: 0.74.1
5
5
  ---
6
6
 
7
7
  <!-- BEGIN shell-contract (managed by scripts/sync-skill-contract.sh — edit skills/_partials/shell-contract.md) -->