@noodleseed/one 0.169.0 → 0.171.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/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/capabilities.d.ts +19 -0
- package/dist/commands/capabilities.d.ts.map +1 -0
- package/dist/commands/capabilities.js +128 -0
- package/dist/commands/capabilities.js.map +1 -0
- package/dist/commands/catalog.d.ts.map +1 -1
- package/dist/commands/catalog.js +2 -1
- package/dist/commands/catalog.js.map +1 -1
- package/dist/commands/whatsapp-ops.d.ts +13 -0
- package/dist/commands/whatsapp-ops.d.ts.map +1 -0
- package/dist/commands/whatsapp-ops.js +244 -0
- package/dist/commands/whatsapp-ops.js.map +1 -0
- package/dist/commands/whatsapp-output.d.ts +3 -0
- package/dist/commands/whatsapp-output.d.ts.map +1 -0
- package/dist/commands/whatsapp-output.js +70 -0
- package/dist/commands/whatsapp-output.js.map +1 -0
- package/dist/dev.js +2 -0
- package/dist/dev.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin-mode/plugin-operation-contract.d.ts +3 -3
- package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +8 -0
- package/node_modules/@noodle-borg/agent-kit/dist/curated/error-fixes.js +1 -0
- package/node_modules/@noodle-borg/agent-kit/dist/generated/example-files.js +2 -2
- package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +5 -0
- package/node_modules/@noodle-borg/agent-kit/dist/skill-authoring-refs.js +3 -2
- package/node_modules/@noodle-borg/agent-kit/dist/skill-embedded-assistant-ref.js +6 -0
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/app-audit/dist/audit-embedded-assistant.js +2 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-configuration.js +2 -1
- package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-interactive.d.ts +1 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-interactive.js +4 -1
- package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-model-context.js +9 -4
- package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-turn-context.d.ts +16 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/assistant-turn-context.js +19 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-coordinator.d.ts +145 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-coordinator.js +378 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-inbox.js +160 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-provider-blocks.d.ts +18 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-provider-blocks.js +69 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-spend.js +82 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-store.d.ts +42 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-store.js +76 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-types.d.ts +134 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-types.js +72 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-work.d.ts +20 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/channel-work.js +221 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/messaging-tool-dispatch.d.ts +15 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/messaging-tool-dispatch.js +34 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/model-request.d.ts +19 -1
- package/node_modules/@noodle-borg/assistant-gateway/dist/model-request.js +22 -6
- package/node_modules/@noodle-borg/assistant-gateway/dist/portable.d.ts +7 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/portable.js +7 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-assistant-appearance-store.js +83 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-assistant-elevation.js +151 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-assistant-interaction-writes.js +45 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-assistant-interactions.js +340 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-assistant.js +439 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-channel-store.js +102 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-continuity-store.js +159 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-elevation-store.js +110 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres-embed-store.js +134 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/postgres.js +11 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/public-surface.d.ts +8 -0
- package/node_modules/@noodle-borg/assistant-gateway/dist/public-surface.js +23 -0
- package/node_modules/@noodle-borg/authoring/dist/assistant.d.ts +19 -4
- package/node_modules/@noodle-borg/authoring/dist/assistant.js +51 -20
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +2 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/load-authored.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +2 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +29 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +3 -0
- package/node_modules/@noodle-borg/authoring/dist/server.js +5 -1
- package/node_modules/@noodle-borg/authoring/dist/web-capabilities.d.ts +17 -0
- package/node_modules/@noodle-borg/authoring/dist/web-capabilities.js +15 -0
- package/node_modules/@noodle-borg/authoring/package.json +1 -0
- package/node_modules/@noodle-borg/capabilities/dist/index.js +7 -0
- package/node_modules/@noodle-borg/cli-catalog/dist/catalog-data-channels.js +121 -0
- package/node_modules/@noodle-borg/cli-catalog/dist/catalog-data-hosted-observability.js +102 -0
- package/node_modules/@noodle-borg/cli-catalog/dist/index.js +1 -0
- package/node_modules/@noodle-borg/compiler/dist/artifact/assemble.js +3 -0
- package/node_modules/@noodle-borg/compiler/dist/artifact/config.js +1 -1
- package/node_modules/@noodle-borg/compiler/dist/artifact/types.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/artifact/version.d.ts +2 -1
- package/node_modules/@noodle-borg/compiler/dist/artifact/version.js +2 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +2 -0
- package/node_modules/@noodle-borg/compiler/dist/errors.d.ts +1 -1
- package/node_modules/@noodle-borg/compiler/dist/fulfilment-emit.js +18 -3
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +106 -12
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +60 -29
- package/node_modules/@noodle-borg/compiler/dist/manifest/website-projection.d.ts +1 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/website-projection.js +19 -0
- package/node_modules/@noodle-borg/compiler/dist/web-capabilities.js +55 -0
- package/node_modules/@noodle-borg/compiler/package.json +1 -0
- package/node_modules/@noodle-borg/connector-http/dist/ssrf.js +5 -0
- package/node_modules/@noodle-borg/knowledge-crawl/dist/bounded-body.js +38 -0
- package/node_modules/@noodle-borg/knowledge-crawl/dist/first-party.js +2 -3
- package/node_modules/@noodle-borg/knowledge-crawl/dist/html-text.js +10 -2
- package/node_modules/@noodle-borg/knowledge-crawl/dist/index.d.ts +1 -0
- package/node_modules/@noodle-borg/knowledge-crawl/dist/index.js +1 -0
- package/node_modules/@noodle-borg/knowledge-crawl/dist/page-reader.d.ts +26 -0
- package/node_modules/@noodle-borg/knowledge-crawl/dist/page-reader.js +127 -0
- package/node_modules/@noodle-borg/knowledge-crawl/dist/robots.js +48 -23
- package/node_modules/@noodle-borg/knowledge-crawl/package.json +1 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/budget.d.ts +29 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/budget.js +124 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/contracts.d.ts +212 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/contracts.js +113 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/errors.d.ts +8 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/errors.js +21 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/executor.d.ts +26 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/executor.js +156 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/limits.d.ts +15 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/limits.js +15 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/operator-contracts.d.ts +159 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/operator-contracts.js +69 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/operator-route.d.ts +5 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/operator-route.js +160 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/policy-store.d.ts +34 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/policy-store.js +61 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/portable.d.ts +10 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/portable.js +10 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/service.d.ts +83 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/service.js +139 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/urls.d.ts +3 -0
- package/node_modules/@noodle-borg/managed-capabilities/dist/urls.js +30 -0
- package/node_modules/@noodle-borg/managed-capabilities/package.json +49 -0
- package/node_modules/@noodle-borg/module/dist/contract.d.ts +11 -0
- package/node_modules/@noodle-borg/module-audit/dist/index.js +37 -0
- package/node_modules/@noodle-borg/module-audit/dist/postgres-audit.js +126 -0
- package/node_modules/@noodle-borg/module-audit/dist/route.js +66 -0
- package/node_modules/@noodle-borg/runtime/dist/confirmation.js +29 -0
- package/node_modules/@noodle-borg/runtime/dist/connector/types.d.ts +2 -0
- package/node_modules/@noodle-borg/runtime/dist/execute.d.ts +3 -0
- package/node_modules/@noodle-borg/runtime/dist/execute.js +6 -1
- package/node_modules/@noodle-borg/runtime/dist/index.d.ts +2 -1
- package/node_modules/@noodle-borg/runtime/dist/index.js +2 -1
- package/node_modules/@noodle-borg/runtime/dist/interactive.js +10 -1
- package/node_modules/@noodle-borg/runtime/dist/managed-origins.js +8 -4
- package/node_modules/@noodle-borg/runtime/dist/operation-execution.js +3 -0
- package/node_modules/@noodle-borg/runtime/dist/postgres-state-handles.js +311 -0
- package/node_modules/@noodle-borg/runtime/dist/postgres.js +4 -0
- package/node_modules/@noodle-borg/runtime/dist/result-meta.d.ts +2 -0
- package/node_modules/@noodle-borg/runtime/dist/result-meta.js +6 -0
- package/node_modules/@noodle-borg/runtime/dist/result.d.ts +4 -0
- package/node_modules/@noodle-borg/runtime/dist/web-capabilities.d.ts +71 -0
- package/node_modules/@noodle-borg/runtime/dist/web-capabilities.js +41 -0
- package/node_modules/@noodle-borg/runtime/package.json +1 -0
- package/node_modules/@noodle-borg/service/dist/assistant-composition.js +18 -0
- package/node_modules/@noodle-borg/service/dist/build-info.js +5 -2
- package/node_modules/@noodle-borg/service/dist/business-information/source-ingestion-coordinator.js +7 -0
- package/node_modules/@noodle-borg/service/dist/channels/360dialog.js +233 -0
- package/node_modules/@noodle-borg/service/dist/channels/cipher.js +37 -0
- package/node_modules/@noodle-borg/service/dist/channels/composition.js +37 -0
- package/node_modules/@noodle-borg/service/dist/channels/inference-guard.js +53 -0
- package/node_modules/@noodle-borg/service/dist/channels/runtime.js +337 -0
- package/node_modules/@noodle-borg/service/dist/channels/worker-loop.js +50 -0
- package/node_modules/@noodle-borg/service/dist/local-options.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/local-web-capabilities.js +13 -0
- package/node_modules/@noodle-borg/service/dist/mcp-protocol-runtime.js +21 -0
- package/node_modules/@noodle-borg/service/dist/modules/route-dispatch.js +13 -0
- package/node_modules/@noodle-borg/service/dist/registry-compile.js +3 -0
- package/node_modules/@noodle-borg/service/dist/registry-types.d.ts +1 -0
- package/node_modules/@noodle-borg/service/dist/registry.js +3 -0
- package/node_modules/@noodle-borg/service/dist/routes/assistant-agent.js +66 -35
- package/node_modules/@noodle-borg/service/dist/routes/assistant-interactions.js +7 -4
- package/node_modules/@noodle-borg/service/dist/routes/assistant-model-binding.js +6 -2
- package/node_modules/@noodle-borg/service/dist/routes/business-information-channels.js +14 -1
- package/node_modules/@noodle-borg/service/dist/routes/whatsapp.js +238 -0
- package/node_modules/@noodle-borg/service/dist/serve-local.js +14 -0
- package/node_modules/@noodle-borg/service/dist/serve-resource-auth.js +10 -0
- package/node_modules/@noodle-borg/service/dist/service.js +37 -33
- package/node_modules/@noodle-borg/service/dist/web-capabilities.js +39 -0
- package/node_modules/@noodle-borg/service/package.json +3 -1
- package/node_modules/@noodle-borg/wire-contracts/dist/application-channels.d.ts +33 -0
- package/node_modules/@noodle-borg/wire-contracts/dist/application-channels.js +9 -0
- package/node_modules/@noodle-borg/wire-contracts/dist/index.d.ts +2 -0
- package/node_modules/@noodle-borg/wire-contracts/dist/index.js +2 -0
- package/node_modules/@noodle-borg/wire-contracts/dist/service-info.d.ts +2 -0
- package/node_modules/@noodle-borg/wire-contracts/dist/service-info.js +10 -2
- package/node_modules/@noodle-borg/wire-contracts/dist/whatsapp.d.ts +426 -0
- package/node_modules/@noodle-borg/wire-contracts/dist/whatsapp.js +213 -0
- package/node_modules/@noodle-borg/wire-contracts/package.json +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { AUDIT_SCHEMA_VERSION, redactDetails, } from '@noodle-borg/module';
|
|
3
|
+
/**
|
|
4
|
+
* Create the append-only `audit_events` table if absent (idempotent; run once at startup). Unlike
|
|
5
|
+
* `deploy_records`/`config_values`, this table has **no foreign key to `environments`** — audit evidence
|
|
6
|
+
* must survive tenant/app/env deletion, so it carries plain `org_slug`/`app_slug`/`environment` text and is
|
|
7
|
+
* never cascade-deleted. `seq` (bigserial) gives a stable newest-first order and a future cursor for the
|
|
8
|
+
* audit query API; `details` is `jsonb` holding the already-redacted scalar bag.
|
|
9
|
+
*/
|
|
10
|
+
export async function ensureAuditSchema(pool) {
|
|
11
|
+
await pool.query(`
|
|
12
|
+
CREATE TABLE IF NOT EXISTS audit_events (
|
|
13
|
+
seq bigserial PRIMARY KEY,
|
|
14
|
+
id uuid NOT NULL,
|
|
15
|
+
event_type text NOT NULL,
|
|
16
|
+
org_slug text NOT NULL,
|
|
17
|
+
app_slug text,
|
|
18
|
+
environment text,
|
|
19
|
+
deployment_id text,
|
|
20
|
+
actor_subject text,
|
|
21
|
+
actor_email text,
|
|
22
|
+
decision text,
|
|
23
|
+
status text,
|
|
24
|
+
reason_code text,
|
|
25
|
+
schema_version int NOT NULL,
|
|
26
|
+
details jsonb,
|
|
27
|
+
created_at timestamptz NOT NULL
|
|
28
|
+
)
|
|
29
|
+
`);
|
|
30
|
+
await pool.query(`
|
|
31
|
+
CREATE INDEX IF NOT EXISTS audit_events_tenant_time_idx
|
|
32
|
+
ON audit_events (org_slug, app_slug, environment, seq DESC)
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Insert one canonical, redacted audit row through either a pool or an already-open transaction client.
|
|
37
|
+
* This helper deliberately does not manage a transaction: callers using a `PoolClient` keep the audit
|
|
38
|
+
* evidence in the same commit boundary as the state change it records.
|
|
39
|
+
*/
|
|
40
|
+
export async function insertAuditEvent(queryable, input, options = {}) {
|
|
41
|
+
const details = redactDetails(input.details);
|
|
42
|
+
await queryable.query(`INSERT INTO audit_events
|
|
43
|
+
(id, event_type, org_slug, app_slug, environment, deployment_id, actor_subject, actor_email,
|
|
44
|
+
decision, status, reason_code, schema_version, details, created_at)
|
|
45
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)`, [
|
|
46
|
+
(options.id ?? randomUUID)(),
|
|
47
|
+
input.eventType,
|
|
48
|
+
input.org,
|
|
49
|
+
input.app ?? null,
|
|
50
|
+
input.env ?? null,
|
|
51
|
+
input.deploymentId ?? null,
|
|
52
|
+
input.actorSubject ?? null,
|
|
53
|
+
input.actorEmail ?? null,
|
|
54
|
+
input.decision ?? null,
|
|
55
|
+
input.status !== undefined ? String(input.status) : null,
|
|
56
|
+
input.reasonCode ?? null,
|
|
57
|
+
AUDIT_SCHEMA_VERSION,
|
|
58
|
+
details !== undefined ? JSON.stringify(details) : null,
|
|
59
|
+
(options.now ?? (() => new Date()))(),
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Relational system of record for {@link AuditEvent}s (parallels {@link InMemoryAuditStore}). The `pg.Pool`
|
|
64
|
+
* is injected; this class is pure SQL and unit-testable against any local Postgres.
|
|
65
|
+
*/
|
|
66
|
+
export class PostgresAuditStore {
|
|
67
|
+
#pool;
|
|
68
|
+
#now;
|
|
69
|
+
#id;
|
|
70
|
+
constructor(pool, options = {}) {
|
|
71
|
+
this.#pool = pool;
|
|
72
|
+
this.#now = options.now ?? (() => new Date());
|
|
73
|
+
this.#id = options.id ?? randomUUID;
|
|
74
|
+
}
|
|
75
|
+
ensureSchema() {
|
|
76
|
+
return ensureAuditSchema(this.#pool);
|
|
77
|
+
}
|
|
78
|
+
async emit(input) {
|
|
79
|
+
await insertAuditEvent(this.#pool, input, { now: this.#now, id: this.#id });
|
|
80
|
+
}
|
|
81
|
+
async list(filter) {
|
|
82
|
+
const org = validateSlug('org', filter.org);
|
|
83
|
+
const clauses = ['org_slug = $1'];
|
|
84
|
+
const values = [org];
|
|
85
|
+
if (filter.app !== undefined) {
|
|
86
|
+
values.push(filter.app);
|
|
87
|
+
clauses.push(`app_slug = $${values.length}`);
|
|
88
|
+
}
|
|
89
|
+
if (filter.env !== undefined) {
|
|
90
|
+
values.push(filter.env);
|
|
91
|
+
clauses.push(`environment = $${values.length}`);
|
|
92
|
+
}
|
|
93
|
+
if (filter.eventType !== undefined) {
|
|
94
|
+
values.push(filter.eventType);
|
|
95
|
+
clauses.push(`event_type = $${values.length}`);
|
|
96
|
+
}
|
|
97
|
+
const limit = filter.limit !== undefined ? ` LIMIT ${Number(filter.limit)}` : '';
|
|
98
|
+
const { rows } = await this.#pool.query(`SELECT * FROM audit_events WHERE ${clauses.join(' AND ')} ORDER BY seq DESC${limit}`, values);
|
|
99
|
+
return rows.map(rowToEvent);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function rowToEvent(row) {
|
|
103
|
+
return {
|
|
104
|
+
id: row.id,
|
|
105
|
+
schemaVersion: row.schema_version,
|
|
106
|
+
eventType: row.event_type,
|
|
107
|
+
org: row.org_slug,
|
|
108
|
+
createdAt: row.created_at.toISOString(),
|
|
109
|
+
...(row.app_slug !== null ? { app: row.app_slug } : {}),
|
|
110
|
+
...(row.environment !== null ? { env: row.environment } : {}),
|
|
111
|
+
...(row.deployment_id !== null ? { deploymentId: row.deployment_id } : {}),
|
|
112
|
+
...(row.actor_subject !== null ? { actorSubject: row.actor_subject } : {}),
|
|
113
|
+
...(row.actor_email !== null ? { actorEmail: row.actor_email } : {}),
|
|
114
|
+
...(row.decision !== null ? { decision: row.decision } : {}),
|
|
115
|
+
...(row.status !== null ? { status: row.status } : {}),
|
|
116
|
+
...(row.reason_code !== null ? { reasonCode: row.reason_code } : {}),
|
|
117
|
+
...(row.details !== null ? { details: row.details } : {}),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function validateSlug(label, value) {
|
|
121
|
+
if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(value)) {
|
|
122
|
+
throw new Error(`${label} must be a lowercase slug`);
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=postgres-audit.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export function createAuditEventsRoute(store) {
|
|
2
|
+
return {
|
|
3
|
+
id: 'audit.events',
|
|
4
|
+
match: (method, url) => method === 'GET' && url.pathname === '/v1/audit/events',
|
|
5
|
+
handle: async (req, res, ctx) => {
|
|
6
|
+
if (ctx.controlPlane === undefined) {
|
|
7
|
+
return sendJson(res, 401, { error: 'control-plane authentication required' });
|
|
8
|
+
}
|
|
9
|
+
const auth = await ctx.controlPlane.authorize(req);
|
|
10
|
+
if (!auth.ok) {
|
|
11
|
+
return sendJson(res, auth.status, { error: auth.message });
|
|
12
|
+
}
|
|
13
|
+
if (auth.identity === undefined) {
|
|
14
|
+
return sendJson(res, 401, { error: 'identity required' });
|
|
15
|
+
}
|
|
16
|
+
if (!auth.identity.superAdmin) {
|
|
17
|
+
return sendJson(res, 403, { error: 'forbidden' });
|
|
18
|
+
}
|
|
19
|
+
const url = new URL(req.url ?? '/', 'http://localhost');
|
|
20
|
+
const org = url.searchParams.get('org');
|
|
21
|
+
if (org === null || org.length === 0) {
|
|
22
|
+
return sendJson(res, 400, { error: 'org query parameter is required' });
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const filter = auditFilterFromQuery(url, org);
|
|
26
|
+
const events = await store.list(filter);
|
|
27
|
+
return sendJson(res, 200, { ok: true, events });
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return sendJson(res, 400, { error: error.message });
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function auditFilterFromQuery(url, org) {
|
|
36
|
+
const app = optionalQuery(url, 'app');
|
|
37
|
+
const env = optionalQuery(url, 'env');
|
|
38
|
+
const eventType = optionalQuery(url, 'eventType');
|
|
39
|
+
const limit = parseLimit(optionalQuery(url, 'limit'));
|
|
40
|
+
return {
|
|
41
|
+
org,
|
|
42
|
+
...(app !== undefined ? { app } : {}),
|
|
43
|
+
...(env !== undefined ? { env } : {}),
|
|
44
|
+
...(eventType !== undefined ? { eventType } : {}),
|
|
45
|
+
...(limit !== undefined ? { limit } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function optionalQuery(url, key) {
|
|
49
|
+
const value = url.searchParams.get(key);
|
|
50
|
+
return value !== null && value.length > 0 ? value : undefined;
|
|
51
|
+
}
|
|
52
|
+
function parseLimit(value) {
|
|
53
|
+
if (value === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
const parsed = Number(value);
|
|
56
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 500) {
|
|
57
|
+
throw new Error('limit must be an integer from 1 to 500');
|
|
58
|
+
}
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
function sendJson(res, status, body) {
|
|
62
|
+
res.statusCode = status;
|
|
63
|
+
res.setHeader('content-type', 'application/json');
|
|
64
|
+
res.end(JSON.stringify(body));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CapabilityBudget } from '@noodle-borg/managed-capabilities';
|
|
1
2
|
import { resolveVariableEnvironment, validateVariableContinuation } from './business-variables.js';
|
|
2
3
|
import { analyzeEligibleActions, countTrailingEligibleOperations, isActionOperation, validateConfirmationFlow, } from './confirmation-analysis.js';
|
|
3
4
|
import { artifactIdentity, confirmationRequired, sameArtifact, } from './confirmation-continuation.js';
|
|
@@ -10,12 +11,32 @@ import { createHost, evalExprMap, prepareOperationAction, resolveEnv, runOperati
|
|
|
10
11
|
import { AllowAllPolicy } from './policy/allow-all.js';
|
|
11
12
|
import { attachResultMeta, splitResultMeta } from './result-meta.js';
|
|
12
13
|
import { admitToolDispatch, latchToolDispatchAdmission } from './tool-dispatch.js';
|
|
14
|
+
function carryBudget(result, budget) {
|
|
15
|
+
if (result.status === 'input_required')
|
|
16
|
+
return {
|
|
17
|
+
...result,
|
|
18
|
+
continuation: { ...result.continuation, capabilityBudget: budget.snapshot() },
|
|
19
|
+
};
|
|
20
|
+
if (result.status === 'confirmation_required')
|
|
21
|
+
return {
|
|
22
|
+
...result,
|
|
23
|
+
continuation: { ...result.continuation, capabilityBudget: budget.snapshot() },
|
|
24
|
+
};
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
13
27
|
/**
|
|
14
28
|
* Evaluate the pure prefix of a confirmable tool. Connector operations are an absolute suspension
|
|
15
29
|
* boundary: this function either requests input, returns a prepared confirmation, or fails before
|
|
16
30
|
* invoking one.
|
|
17
31
|
*/
|
|
18
32
|
export async function prepareToolForConfirmation(artifact, toolName, input, deps) {
|
|
33
|
+
const capabilityBudget = deps.capabilityBudget ?? new CapabilityBudget();
|
|
34
|
+
return carryBudget(await prepareToolForConfirmationInternal(artifact, toolName, input, {
|
|
35
|
+
...deps,
|
|
36
|
+
capabilityBudget,
|
|
37
|
+
}), capabilityBudget);
|
|
38
|
+
}
|
|
39
|
+
async function prepareToolForConfirmationInternal(artifact, toolName, input, deps) {
|
|
19
40
|
if (artifact.resolution !== 'resolved') {
|
|
20
41
|
return failPreparation('shape_only_artifact', 'runtime refuses to serve a shape-only artifact');
|
|
21
42
|
}
|
|
@@ -52,6 +73,13 @@ export async function prepareToolForConfirmation(artifact, toolName, input, deps
|
|
|
52
73
|
}
|
|
53
74
|
/** Resume the pure preparation prefix with one accepted, declined, or cancelled input response. */
|
|
54
75
|
export async function resumeToolPreparation(artifact, continuation, response, deps) {
|
|
76
|
+
const capabilityBudget = new CapabilityBudget(continuation.capabilityBudget);
|
|
77
|
+
return carryBudget(await resumeToolPreparationInternal(artifact, continuation, response, {
|
|
78
|
+
...deps,
|
|
79
|
+
capabilityBudget,
|
|
80
|
+
}), capabilityBudget);
|
|
81
|
+
}
|
|
82
|
+
async function resumeToolPreparationInternal(artifact, continuation, response, deps) {
|
|
55
83
|
if (artifact.resolution !== 'resolved') {
|
|
56
84
|
return failPreparation('shape_only_artifact', 'runtime refuses to serve a shape-only artifact');
|
|
57
85
|
}
|
|
@@ -94,6 +122,7 @@ export async function resumeToolPreparation(artifact, continuation, response, de
|
|
|
94
122
|
* after performing a side effect.
|
|
95
123
|
*/
|
|
96
124
|
export async function executePreparedTool(artifact, continuation, deps) {
|
|
125
|
+
deps = { ...deps, capabilityBudget: new CapabilityBudget(continuation.capabilityBudget) };
|
|
97
126
|
if (artifact.resolution !== 'resolved') {
|
|
98
127
|
return failInteractive('shape_only_artifact', 'runtime refuses to serve a shape-only artifact');
|
|
99
128
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CredentialProfile, OperationSignature, ResolvedOperationRef } from '@noodle-borg/compiler';
|
|
2
|
+
import type { CapabilityBudget } from '@noodle-borg/managed-capabilities';
|
|
2
3
|
import type { DownstreamCredential } from '../broker/types.js';
|
|
3
4
|
import type { CustomerConnectorRoute } from '../customer-routing.js';
|
|
4
5
|
import type { OperationCoordinationDeclaration, OperationCoordinationSnapshot } from '../operation-coordination.js';
|
|
@@ -81,6 +82,7 @@ export interface ConnectorCallHost {
|
|
|
81
82
|
}
|
|
82
83
|
/** A single connector-operation invocation, fully resolved and credentialed by the runtime. */
|
|
83
84
|
export interface ConnectorCall {
|
|
85
|
+
readonly capabilityBudget?: CapabilityBudget;
|
|
84
86
|
readonly operation: string;
|
|
85
87
|
/** Runtime-generated, deployment/step-bound identity. Not a business input or recovery authority. */
|
|
86
88
|
readonly execution?: Readonly<{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ArtifactFulfilment, RuntimeArtifact } from '@noodle-borg/compiler';
|
|
2
|
+
import { CapabilityBudget } from '@noodle-borg/managed-capabilities';
|
|
2
3
|
import type { CredentialBroker } from './broker/types.js';
|
|
3
4
|
import type { CallerIdentity, ConnectorRegistry, ExecutionTraceSink } from './connector/types.js';
|
|
4
5
|
import type { FrozenCustomerRoutes } from './customer-routing.js';
|
|
@@ -18,6 +19,8 @@ export { evalExprMap, validateAgainstSchema, validateAgainstSchemaWithDefaults,
|
|
|
18
19
|
* [ADR 0005](../../../docs/decisions/0005-runtime-execution-boundary.md)).
|
|
19
20
|
*/
|
|
20
21
|
export interface ExecuteDeps {
|
|
22
|
+
/** Trusted shared assistant-turn / MCP-invocation budget; never part of the expression scope. */
|
|
23
|
+
readonly capabilityBudget?: CapabilityBudget;
|
|
21
24
|
readonly connectors: ConnectorRegistry;
|
|
22
25
|
readonly broker: CredentialBroker;
|
|
23
26
|
readonly policy?: PolicyGate;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CapabilityBudget } from '@noodle-borg/managed-capabilities';
|
|
1
2
|
import { resolveVariableEnvironment } from './business-variables.js';
|
|
2
3
|
import { preflightFulfilmentSignatures } from './connector-snapshot.js';
|
|
3
4
|
import { preflightFulfilmentCustomerRoutes } from './customer-routing.js';
|
|
@@ -29,7 +30,11 @@ export async function executeTool(artifact, toolName, input, deps) {
|
|
|
29
30
|
const variables = resolveVariableEnvironment(artifact.server.variables ?? [], await resolveEnv(deps), toolName);
|
|
30
31
|
if (!variables.ok)
|
|
31
32
|
return variables;
|
|
32
|
-
return runFulfilment(tool.fulfilment, input, toolName, {
|
|
33
|
+
return runFulfilment(tool.fulfilment, input, toolName, {
|
|
34
|
+
...deps,
|
|
35
|
+
env: variables.env,
|
|
36
|
+
capabilityBudget: deps.capabilityBudget ?? new CapabilityBudget(),
|
|
37
|
+
}, deps.beforeDispatch);
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Execute a resource read against a resolved artifact. `input` is the resource's variable scope — the
|
|
@@ -20,8 +20,9 @@ export type { OperationEvidence, OperationEvidenceIntent, OperationEvidencePort,
|
|
|
20
20
|
export { AllowAllPolicy } from './policy/allow-all.js';
|
|
21
21
|
export type { PolicyContext, PolicyDecision, PolicyGate } from './policy/types.js';
|
|
22
22
|
export { type ConfirmationActionReview, type ConfirmationPreparationResult, type ConfirmationReview, type ConnectorFailureAttribution, type ElicitationRequest, type ElicitationResponse, type ExecutionError, type ExecutionErrorCode, type ExecutionResult, type InteractiveExecutionResult, isConfirmationRequired, isInputRequired, isInputRequiredForConfirmation, type PreparedOperationAction, type PreparedToolContinuation, type ToolContinuation, type ToolPreparationContinuation, } from './result.js';
|
|
23
|
-
export { splitResultMeta } from './result-meta.js';
|
|
23
|
+
export { hasEphemeralEvidence, splitResultMeta } from './result-meta.js';
|
|
24
24
|
export { type CallerStateAdoptionInput, type CallerStateAdoptionResult, claimableStateHandleNames, } from './state-handle-ownership.js';
|
|
25
25
|
export { assertExpectedStateRevision, assertNoSecretValue, assertSchemaValue, assertStateHandleNotCompleted, COMPLETE_STATE_OPERATION, createMutableStateHandleRecord, createStateConnector, InMemoryStateHandleStore, type MutableStateHandleRecord, PATCH_STATE_OPERATION, READ_STATE_OPERATION, STATE_CONNECTOR_ID, STATE_CONNECTOR_VERSION, STATE_OPERATION_SIGNATURES, StateConnector, type StateHandleRecord, type StateHandleStore, type StateInput, type StateMutationInput, type StatePatchInput, stateHandleRecordForMutation, toPublicStateHandleRecord, } from './state-handles.js';
|
|
26
26
|
export type { ToolDispatchContext, ToolDispatchDecision, ToolDispatchHook, } from './tool-dispatch.js';
|
|
27
|
+
export { WebCapabilityConnector, type WebCapabilityExecutionPort } from './web-capabilities.js';
|
|
27
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -15,7 +15,8 @@ export { executeToolInteractive, resumeTool } from './interactive.js';
|
|
|
15
15
|
export { resolveManagedOrigins, } from './managed-origins.js';
|
|
16
16
|
export { AllowAllPolicy } from './policy/allow-all.js';
|
|
17
17
|
export { isConfirmationRequired, isInputRequired, isInputRequiredForConfirmation, } from './result.js';
|
|
18
|
-
export { splitResultMeta } from './result-meta.js';
|
|
18
|
+
export { hasEphemeralEvidence, splitResultMeta } from './result-meta.js';
|
|
19
19
|
export { claimableStateHandleNames, } from './state-handle-ownership.js';
|
|
20
20
|
export { assertExpectedStateRevision, assertNoSecretValue, assertSchemaValue, assertStateHandleNotCompleted, COMPLETE_STATE_OPERATION, createMutableStateHandleRecord, createStateConnector, InMemoryStateHandleStore, PATCH_STATE_OPERATION, READ_STATE_OPERATION, STATE_CONNECTOR_ID, STATE_CONNECTOR_VERSION, STATE_OPERATION_SIGNATURES, StateConnector, stateHandleRecordForMutation, toPublicStateHandleRecord, } from './state-handles.js';
|
|
21
|
+
export { WebCapabilityConnector } from './web-capabilities.js';
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CapabilityBudget } from '@noodle-borg/managed-capabilities';
|
|
1
2
|
import { resolveVariableEnvironment, validateVariableContinuation } from './business-variables.js';
|
|
2
3
|
import { preflightFulfilmentCustomerRoutes } from './customer-routing.js';
|
|
3
4
|
import { validateElicitationContent } from './elicitation-response.js';
|
|
@@ -17,7 +18,11 @@ export async function executeToolInteractive(artifact, toolName, input, deps) {
|
|
|
17
18
|
const variables = resolveVariableEnvironment(artifact.server.variables ?? [], await resolveEnv(deps), toolName);
|
|
18
19
|
if (!variables.ok)
|
|
19
20
|
return { status: 'failed', error: variables.error };
|
|
20
|
-
deps = {
|
|
21
|
+
deps = {
|
|
22
|
+
...deps,
|
|
23
|
+
env: variables.env,
|
|
24
|
+
capabilityBudget: deps.capabilityBudget ?? new CapabilityBudget(),
|
|
25
|
+
};
|
|
21
26
|
if (tool.fulfilment.kind !== 'flow' || !tool.fulfilment.steps.some((s) => s.kind === 'elicit')) {
|
|
22
27
|
return toInteractive(await runFulfilment(tool.fulfilment, input, toolName, deps, deps.beforeDispatch));
|
|
23
28
|
}
|
|
@@ -32,6 +37,7 @@ export async function executeToolInteractive(artifact, toolName, input, deps) {
|
|
|
32
37
|
}
|
|
33
38
|
/** Resume one server-held continuation with the user's reviewed response. */
|
|
34
39
|
export async function resumeTool(artifact, continuation, response, deps) {
|
|
40
|
+
deps = { ...deps, capabilityBudget: new CapabilityBudget(continuation.capabilityBudget) };
|
|
35
41
|
if (!sameArtifact(artifact, continuation) || continuation.version !== 1) {
|
|
36
42
|
return interactiveFail('invalid_continuation', 'tool continuation does not match the artifact');
|
|
37
43
|
}
|
|
@@ -84,6 +90,9 @@ async function runInteractiveFlow(artifact, toolName, flow, input, startIndex, s
|
|
|
84
90
|
status: 'input_required',
|
|
85
91
|
request,
|
|
86
92
|
continuation: {
|
|
93
|
+
...(deps.capabilityBudget === undefined
|
|
94
|
+
? {}
|
|
95
|
+
: { capabilityBudget: deps.capabilityBudget.snapshot() }),
|
|
87
96
|
version: 1,
|
|
88
97
|
artifact: artifactIdentity(artifact),
|
|
89
98
|
toolName,
|
|
@@ -14,10 +14,12 @@ export function resolveManagedOrigins(artifact, variables, options = {}) {
|
|
|
14
14
|
...(assistant.surfaces === undefined
|
|
15
15
|
? {}
|
|
16
16
|
: {
|
|
17
|
-
surfaces: assistant.surfaces.map((surface, index) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
surfaces: assistant.surfaces.map((surface, index) => surface.kind === 'messaging'
|
|
18
|
+
? surface
|
|
19
|
+
: {
|
|
20
|
+
...surface,
|
|
21
|
+
origins: resolveList(surface.origins, `server.assistant.surfaces.${index}.origins`, true),
|
|
22
|
+
}),
|
|
21
23
|
}),
|
|
22
24
|
};
|
|
23
25
|
const handoff = artifact.server.handoff;
|
|
@@ -29,6 +31,8 @@ export function resolveManagedOrigins(artifact, variables, options = {}) {
|
|
|
29
31
|
};
|
|
30
32
|
const owners = new Map();
|
|
31
33
|
resolvedAssistant?.surfaces?.forEach((surface, index) => {
|
|
34
|
+
if (surface.kind === 'messaging')
|
|
35
|
+
return;
|
|
32
36
|
for (const origin of surface.origins) {
|
|
33
37
|
const prior = owners.get(origin);
|
|
34
38
|
if (prior !== undefined && prior !== index)
|
|
@@ -224,6 +224,9 @@ async function invokeOperation(ref, args, sig, toolName, deps, policy, host, env
|
|
|
224
224
|
if (signal?.aborted)
|
|
225
225
|
return fail('execution_cancelled', 'Execution deadline elapsed before connector dispatch.');
|
|
226
226
|
output = await connector.invoke({
|
|
227
|
+
...(deps.capabilityBudget === undefined
|
|
228
|
+
? {}
|
|
229
|
+
: { capabilityBudget: deps.capabilityBudget }),
|
|
227
230
|
operation: ref.operation,
|
|
228
231
|
execution,
|
|
229
232
|
reportOutcome: (value) => {
|