@method-ai-hq/sdk 0.0.0-stage → 0.14.3
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/LICENSE +21 -0
- package/README.md +23 -2
- package/dist/packages/contracts/src/identity.d.ts +16 -0
- package/dist/packages/contracts/src/identity.js +41 -0
- package/dist/packages/contracts/src/method-package.d.ts +71 -0
- package/dist/packages/contracts/src/method-package.js +22 -0
- package/dist/packages/method-document/src/conversion-report.d.ts +138 -0
- package/dist/packages/method-document/src/conversion-report.js +23 -0
- package/dist/packages/sdk/examples/daily-briefing/README.md +31 -0
- package/dist/packages/sdk/examples/daily-briefing/TASK.md +3 -0
- package/dist/packages/sdk/examples/daily-briefing/approved-report.md +138 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_artifacts.py +39 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_check_inputs.py +47 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_files.py +31 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_manifest.py +23 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_markdown.py +67 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_progress.py +18 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_render.py +71 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_sessions.py +37 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_times.py +158 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_validation.py +101 -0
- package/dist/packages/sdk/examples/daily-briefing/briefing_website.py +215 -0
- package/dist/packages/sdk/examples/daily-briefing/checks.json +19 -0
- package/dist/packages/sdk/examples/daily-briefing/daily-briefing.method +158 -0
- package/dist/packages/sdk/examples/daily-briefing/inputs.json +1 -0
- package/dist/packages/sdk/examples/daily-briefing/package-lock.json +10 -0
- package/dist/packages/sdk/examples/daily-briefing/package.json +4 -0
- package/dist/packages/sdk/examples/daily-briefing/pyproject.toml +8 -0
- package/dist/packages/sdk/examples/daily-briefing/reader/reader.css +35 -0
- package/dist/packages/sdk/examples/daily-briefing/reader/reader.js +42 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/context.json +1 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/documents/document-001.md +219 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/media.json +1 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/metadata/documents.json +39 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0001.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0002.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0003.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0004.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0005.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0006.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0007.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0008.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0009.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0010.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0011.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0012.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0013.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0014.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0015.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0016.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0017.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0018.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0019.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0020.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0021.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0022.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0023.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0024.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0025.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0026.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0027.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/records/chatgpt-0028.json +49 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/sessions.json +1 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/timeline.jsonl +28 -0
- package/dist/packages/sdk/examples/daily-briefing/sample/untimed.jsonl +0 -0
- package/dist/packages/sdk/examples/daily-briefing/sample-output.zip +0 -0
- package/dist/packages/sdk/examples/daily-briefing/sample-report.md +51 -0
- package/dist/packages/sdk/examples/daily-briefing/uv.lock +128 -0
- package/dist/packages/sdk/examples/daily-briefing/vendor/marked-LICENSE.md +44 -0
- package/dist/packages/sdk/examples/daily-briefing/vendor/marked.mjs +77 -0
- package/dist/packages/sdk/examples/files.json +126 -0
- package/dist/packages/sdk/examples/message-routing/README.md +23 -0
- package/dist/packages/sdk/examples/message-routing/TASK.md +5 -0
- package/dist/packages/sdk/examples/message-routing/choose-destination.mjs +10 -0
- package/dist/packages/sdk/examples/message-routing/create-ticket.mjs +15 -0
- package/dist/packages/sdk/examples/message-routing/inputs.json +1 -0
- package/dist/packages/sdk/examples/message-routing/message-routing.method +45 -0
- package/dist/packages/sdk/examples/message-routing/result.fixture.json +6 -0
- package/dist/packages/sdk/examples/message-routing/routing.mjs +29 -0
- package/dist/packages/sdk/examples/message-routing/routing.test.mjs +27 -0
- package/dist/packages/sdk/examples/message-routing/ticket.method +88 -0
- package/dist/packages/sdk/examples/message-routing/ticket.test.mjs +64 -0
- package/dist/packages/sdk/examples/notes-summary/README.md +23 -0
- package/dist/packages/sdk/examples/notes-summary/TASK.md +3 -0
- package/dist/packages/sdk/examples/notes-summary/cases/dates-in-decisions/case.json +36 -0
- package/dist/packages/sdk/examples/notes-summary/cases/dates-in-decisions/examples.json +16 -0
- package/dist/packages/sdk/examples/notes-summary/cases/dates-in-decisions/files/0 +10 -0
- package/dist/packages/sdk/examples/notes-summary/cases/dates-in-decisions/recording.json +195 -0
- package/dist/packages/sdk/examples/notes-summary/notes/2026-10-05-standup.md +4 -0
- package/dist/packages/sdk/examples/notes-summary/notes/2026-10-07-planning.md +3 -0
- package/dist/packages/sdk/examples/notes-summary/notes-summary.method +54 -0
- package/dist/packages/sdk/examples/notes-summary/out/.keep +0 -0
- package/dist/packages/sdk/examples/notes-summary/read-notes.mjs +4 -0
- package/dist/packages/sdk/examples/notes-summary/save.mjs +7 -0
- package/dist/packages/sdk/examples/outbound-management/README.md +119 -0
- package/dist/packages/sdk/examples/outbound-management/TASK.md +5 -0
- package/dist/packages/sdk/examples/outbound-management/check_plan.py +16 -0
- package/dist/packages/sdk/examples/outbound-management/check_sources.py +14 -0
- package/dist/packages/sdk/examples/outbound-management/crm.py +153 -0
- package/dist/packages/sdk/examples/outbound-management/crm_test.py +141 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/README.md +15 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/crm.json +54 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/day-1/messages.json +29 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/day-2/messages.json +38 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/observations.json +12 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/plan.json +69 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/receipt.json +1 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/state.json +99 -0
- package/dist/packages/sdk/examples/outbound-management/fixtures/tasks.md +16 -0
- package/dist/packages/sdk/examples/outbound-management/inputs.json +4 -0
- package/dist/packages/sdk/examples/outbound-management/outbound.method +277 -0
- package/dist/packages/sdk/examples/outbound-management/read_crm.py +4 -0
- package/dist/packages/sdk/examples/outbound-management/save_day.py +4 -0
- package/dist/packages/sdk/examples/outbound-management/starter/crm.json +11 -0
- package/dist/packages/sdk/examples/social-briefing/README.md +41 -0
- package/dist/packages/sdk/examples/social-briefing/TASK.md +5 -0
- package/dist/packages/sdk/examples/social-briefing/inputs.json +5 -0
- package/dist/packages/sdk/examples/social-briefing/result.fixture.json +14 -0
- package/dist/packages/sdk/examples/social-briefing/social-briefing.method +110 -0
- package/dist/packages/sdk/examples/support-triage/README.md +77 -0
- package/dist/packages/sdk/examples/support-triage/TASK.md +3 -0
- package/dist/packages/sdk/examples/support-triage/cases/double-charge-to-billing/case.json +40 -0
- package/dist/packages/sdk/examples/support-triage/cases/double-charge-to-billing/recording.json +460 -0
- package/dist/packages/sdk/examples/support-triage/fake-helpdesk.mjs +38 -0
- package/dist/packages/sdk/examples/support-triage/helpdesk.mjs +33 -0
- package/dist/packages/sdk/examples/support-triage/inputs.json +1 -0
- package/dist/packages/sdk/examples/support-triage/read-ticket.mjs +8 -0
- package/dist/packages/sdk/examples/support-triage/route.mjs +4 -0
- package/dist/packages/sdk/examples/support-triage/sample-tickets.json +5 -0
- package/dist/packages/sdk/examples/support-triage/set-ticket.mjs +9 -0
- package/dist/packages/sdk/examples/support-triage/support-triage.method +165 -0
- package/dist/packages/sdk/examples/support-triage/triage.mjs +38 -0
- package/dist/packages/sdk/examples/support-triage/triage.test.mjs +68 -0
- package/dist/packages/sdk/observers/mail.delivery/fetch.mjs +87 -0
- package/dist/packages/sdk/observers/mail.delivery/fixtures/bounce-by-recipient.json +1 -0
- package/dist/packages/sdk/observers/mail.delivery/fixtures/bounce.json +1 -0
- package/dist/packages/sdk/observers/mail.delivery/fixtures/delayed.json +1 -0
- package/dist/packages/sdk/observers/mail.delivery/fixtures/delivered.json +1 -0
- package/dist/packages/sdk/observers/mail.delivery/fixtures/empty.json +1 -0
- package/dist/packages/sdk/observers/mail.delivery/fixtures/other-message.json +1 -0
- package/dist/packages/sdk/observers/mail.delivery/judge.mjs +13 -0
- package/dist/packages/sdk/observers/mail.delivery/observer.json +14 -0
- package/dist/packages/sdk/package.json +232 -0
- package/dist/packages/sdk/src/authoring-example.d.ts +91 -0
- package/dist/packages/sdk/src/authoring-example.js +50 -0
- package/dist/packages/sdk/src/authoring-instructions.d.ts +20 -0
- package/dist/packages/sdk/src/authoring-instructions.js +151 -0
- package/dist/packages/sdk/src/authoring-prompt.d.ts +2 -0
- package/dist/packages/sdk/src/authoring-prompt.js +8 -0
- package/dist/packages/sdk/src/authoring.d.ts +10 -0
- package/dist/packages/sdk/src/authoring.js +287 -0
- package/dist/packages/sdk/src/bindings.d.ts +4 -0
- package/dist/packages/sdk/src/bindings.js +124 -0
- package/dist/packages/sdk/src/bridge.d.ts +2 -0
- package/dist/packages/sdk/src/bridge.js +23 -0
- package/dist/packages/sdk/src/browser-runtime/pyproject.toml +5 -0
- package/dist/packages/sdk/src/browser-runtime/tools.json +189 -0
- package/dist/packages/sdk/src/browser-runtime/uv.lock +3894 -0
- package/dist/packages/sdk/src/browser-service.py +127 -0
- package/dist/packages/sdk/src/browser.d.ts +38 -0
- package/dist/packages/sdk/src/browser.js +203 -0
- package/dist/packages/sdk/src/capabilities.d.ts +13 -0
- package/dist/packages/sdk/src/capabilities.js +68 -0
- package/dist/packages/sdk/src/classification-client.d.ts +4 -0
- package/dist/packages/sdk/src/classification-client.js +27 -0
- package/dist/packages/sdk/src/cloud.d.ts +23 -0
- package/dist/packages/sdk/src/cloud.js +43 -0
- package/dist/packages/sdk/src/computer-settings.d.ts +28 -0
- package/dist/packages/sdk/src/computer-settings.js +57 -0
- package/dist/packages/sdk/src/connect.d.ts +47 -0
- package/dist/packages/sdk/src/connect.js +203 -0
- package/dist/packages/sdk/src/current-inspection.d.ts +3 -0
- package/dist/packages/sdk/src/current-inspection.js +146 -0
- package/dist/packages/sdk/src/current-runtime.d.ts +14 -0
- package/dist/packages/sdk/src/current-runtime.js +167 -0
- package/dist/packages/sdk/src/doctor.d.ts +17 -0
- package/dist/packages/sdk/src/doctor.js +68 -0
- package/dist/packages/sdk/src/executable.d.ts +2 -0
- package/dist/packages/sdk/src/executable.js +22 -0
- package/dist/packages/sdk/src/explain-effects.d.ts +32 -0
- package/dist/packages/sdk/src/explain-effects.js +192 -0
- package/dist/packages/sdk/src/explain.d.ts +115 -0
- package/dist/packages/sdk/src/explain.js +441 -0
- package/dist/packages/sdk/src/files.d.ts +9 -0
- package/dist/packages/sdk/src/files.js +50 -0
- package/dist/packages/sdk/src/guard-keys.d.ts +5 -0
- package/dist/packages/sdk/src/guard-keys.js +42 -0
- package/dist/packages/sdk/src/hosted-models.d.ts +49 -0
- package/dist/packages/sdk/src/hosted-models.js +81 -0
- package/dist/packages/sdk/src/improve.d.ts +55 -0
- package/dist/packages/sdk/src/improve.js +159 -0
- package/dist/packages/sdk/src/index.d.ts +13 -0
- package/dist/packages/sdk/src/index.js +13 -0
- package/dist/packages/sdk/src/inspect.d.ts +6 -0
- package/dist/packages/sdk/src/inspect.js +17 -0
- package/dist/packages/sdk/src/link.d.ts +12 -0
- package/dist/packages/sdk/src/link.js +53 -0
- package/dist/packages/sdk/src/local-cli.d.ts +24 -0
- package/dist/packages/sdk/src/local-cli.js +146 -0
- package/dist/packages/sdk/src/local-setup.d.ts +15 -0
- package/dist/packages/sdk/src/local-setup.js +42 -0
- package/dist/packages/sdk/src/method-client.d.ts +30 -0
- package/dist/packages/sdk/src/method-client.js +250 -0
- package/dist/packages/sdk/src/method-files.d.ts +29 -0
- package/dist/packages/sdk/src/method-files.js +93 -0
- package/dist/packages/sdk/src/method-help.d.ts +19 -0
- package/dist/packages/sdk/src/method-help.js +404 -0
- package/dist/packages/sdk/src/method-issues.d.ts +86 -0
- package/dist/packages/sdk/src/method-issues.js +192 -0
- package/dist/packages/sdk/src/method-sync.d.ts +46 -0
- package/dist/packages/sdk/src/method-sync.js +293 -0
- package/dist/packages/sdk/src/method.d.ts +5 -0
- package/dist/packages/sdk/src/method.js +359 -0
- package/dist/packages/sdk/src/model-checks.d.ts +96 -0
- package/dist/packages/sdk/src/model-checks.js +181 -0
- package/dist/packages/sdk/src/outbox.d.ts +120 -0
- package/dist/packages/sdk/src/outbox.js +297 -0
- package/dist/packages/sdk/src/own-model-key.d.ts +22 -0
- package/dist/packages/sdk/src/own-model-key.js +76 -0
- package/dist/packages/sdk/src/prepare.d.ts +24 -0
- package/dist/packages/sdk/src/prepare.js +245 -0
- package/dist/packages/sdk/src/process.d.ts +15 -0
- package/dist/packages/sdk/src/process.js +107 -0
- package/dist/packages/sdk/src/production.d.ts +182 -0
- package/dist/packages/sdk/src/production.js +284 -0
- package/dist/packages/sdk/src/progress.d.ts +12 -0
- package/dist/packages/sdk/src/progress.js +48 -0
- package/dist/packages/sdk/src/proposals.d.ts +73 -0
- package/dist/packages/sdk/src/proposals.js +284 -0
- package/dist/packages/sdk/src/quality.d.ts +82 -0
- package/dist/packages/sdk/src/quality.js +294 -0
- package/dist/packages/sdk/src/result-files.d.ts +5 -0
- package/dist/packages/sdk/src/result-files.js +149 -0
- package/dist/packages/sdk/src/result-transfer.d.ts +21 -0
- package/dist/packages/sdk/src/result-transfer.js +37 -0
- package/dist/packages/sdk/src/run-data.d.ts +11 -0
- package/dist/packages/sdk/src/run-data.js +80 -0
- package/dist/packages/sdk/src/run-method.d.ts +2 -0
- package/dist/packages/sdk/src/run-method.js +2 -0
- package/dist/packages/sdk/src/run-saved.d.ts +5 -0
- package/dist/packages/sdk/src/run-saved.js +138 -0
- package/dist/packages/sdk/src/run-worker.d.ts +6 -0
- package/dist/packages/sdk/src/run-worker.js +131 -0
- package/dist/packages/sdk/src/secrets.d.ts +37 -0
- package/dist/packages/sdk/src/secrets.js +196 -0
- package/dist/packages/sdk/src/update.d.ts +5 -0
- package/dist/packages/sdk/src/update.js +39 -0
- package/dist/packages/sdk/src/versions.d.ts +58 -0
- package/dist/packages/sdk/src/versions.js +144 -0
- package/dist/packages/sdk/src/worker.d.ts +120 -0
- package/dist/packages/sdk/src/worker.js +443 -0
- package/dist/packages/workflow-language/src/execution.d.ts +1 -0
- package/dist/packages/workflow-language/src/execution.js +1 -0
- package/dist/packages/workflow-language/src/inspection.d.ts +990 -0
- package/dist/packages/workflow-language/src/inspection.js +130 -0
- package/dist/packages/workflow-language/src/result-files.d.ts +160 -0
- package/dist/packages/workflow-language/src/result-files.js +67 -0
- package/dist/packages/workflow-language/src/schema.d.ts +207 -0
- package/dist/packages/workflow-language/src/schema.js +56 -0
- package/dist/packages/workflow-language/src/validate.d.ts +11 -0
- package/dist/packages/workflow-language/src/validate.js +77 -0
- package/package.json +230 -4
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { AttachedFileSchema, MAX_RESULT_FILES } from "./result-files.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { JsonSchema, WorkflowSchema, effectiveOutputs, executionText } from "./schema.js";
|
|
4
|
+
import { producers, references, referenceShape } from "./validate.js";
|
|
5
|
+
export const FailureSchema = z.strictObject({ phase: z.enum(["environment", "input", "action", "check", "change"]), expected: z.string(), observed: z.string(), evidence: z.array(z.string()) });
|
|
6
|
+
// What a script process was seen to do (runtime observed_effects): hosts, paths, variable names, and program names.
|
|
7
|
+
const observedList = z.array(z.string()).max(200);
|
|
8
|
+
export const ObservedEffectsSchema = z.union([
|
|
9
|
+
z.strictObject({ network: observedList, reads: observedList, writes: observedList, env: observedList, runs: observedList, truncated: z.literal(true).optional() }),
|
|
10
|
+
z.strictObject({ unavailable: z.string() }),
|
|
11
|
+
]);
|
|
12
|
+
export const RunEventSchema = z.strictObject({
|
|
13
|
+
provider: z.string().optional(), model: z.string().optional(), kind: z.literal('classify').optional(),
|
|
14
|
+
request_id: z.string().optional(), operation_id: z.string().optional(), confidence: z.number().finite().min(0).max(1).nullable().optional(),
|
|
15
|
+
usage: z.strictObject({ input_tokens: z.number().int().nonnegative(), output_tokens: z.number().int().nonnegative(), cost: z.number().finite().nonnegative().optional() }).nullable().optional(),
|
|
16
|
+
duration_ms: z.number().finite().nonnegative().optional(),
|
|
17
|
+
at: z.string(), type: z.string(), detail: z.string().optional(),
|
|
18
|
+
sequence: z.number().int().nonnegative().optional(), phase: z.enum(["action", "check"]).optional(),
|
|
19
|
+
tool: z.string().optional(), call_id: z.string().optional(), command: z.string().optional(),
|
|
20
|
+
exit_code: z.number().int().nullable().optional(), diagnostics: z.string().optional(),
|
|
21
|
+
child: z.string().max(100).optional(), completed: z.number().int().nonnegative().optional(),
|
|
22
|
+
total: z.number().int().positive().optional(), unit: z.string().max(50).optional(),
|
|
23
|
+
});
|
|
24
|
+
export const InspectionSchema = z.strictObject({
|
|
25
|
+
started_at: z.string().optional(), device_name: z.string().optional(),
|
|
26
|
+
local_run_directory: z.string().optional(),
|
|
27
|
+
// run_data: device. The run's content stays on the device that ran it.
|
|
28
|
+
content: z.literal("device").optional(),
|
|
29
|
+
schema: z.literal("workflow-inspection/2"), workflow: WorkflowSchema, run_id: z.string(), status: z.string(), error: z.string().optional(), failure: FailureSchema.optional(),
|
|
30
|
+
inputs: z.record(JsonSchema), state: z.record(JsonSchema).optional(), resources: z.record(z.strictObject({ description: z.string(), setup: z.string().optional(), path: z.string().optional() })),
|
|
31
|
+
environment: z.record(z.object({ result: z.enum(["pass", "fail", "ambiguous"]), summary: z.string(), evidence: z.array(z.string()) })).optional(),
|
|
32
|
+
files: z.array(AttachedFileSchema).max(MAX_RESULT_FILES).optional(),
|
|
33
|
+
events: z.array(RunEventSchema).optional(),
|
|
34
|
+
invocations: z.record(z.strictObject({
|
|
35
|
+
step_id: z.string(), status: z.string(), verification: z.enum(["checked", "unchecked"]).optional(), error: z.string().optional(), failure: FailureSchema.optional(), inputs: z.record(JsonSchema).optional(), outputs: z.record(JsonSchema).optional(),
|
|
36
|
+
checks: z.array(z.object({ id: z.string(), result: z.enum(["pass", "fail", "ambiguous"]), summary: z.string(), evidence: z.array(z.string()), method: z.string() })), changes: z.record(JsonSchema),
|
|
37
|
+
prompts: z.array(z.strictObject({ sequence: z.number().int(), phase: z.enum(["action", "check"]), template: z.string(), rendered: z.string() })).optional(),
|
|
38
|
+
events: z.array(RunEventSchema),
|
|
39
|
+
observed_effects: ObservedEffectsSchema.optional(),
|
|
40
|
+
}))
|
|
41
|
+
});
|
|
42
|
+
export function label(value) { return value.replace(/[_-]+/g, " ").trim(); }
|
|
43
|
+
export function stepTitle(step, id = "Step") { return step.name ?? label(id); }
|
|
44
|
+
export function canonical(value) {
|
|
45
|
+
const sort = (v) => Array.isArray(v) ? v.map(sort) : v && typeof v === "object" ? Object.fromEntries(Object.keys(v).sort().map(k => [k, sort(v[k])])) : v;
|
|
46
|
+
return JSON.stringify(sort(value));
|
|
47
|
+
}
|
|
48
|
+
export function inspectCatalog(workflow) {
|
|
49
|
+
const items = new Map();
|
|
50
|
+
const producer = producers(workflow);
|
|
51
|
+
function itemFor(ref) {
|
|
52
|
+
if (items.has(ref))
|
|
53
|
+
return items.get(ref);
|
|
54
|
+
const parts = ref.split("."), root = parts[0];
|
|
55
|
+
const definition = root === "environment" ? workflow.environment?.[parts[1]] : root === "inputs" ? workflow.inputs?.[parts[1]] : root === "state" ? workflow.state?.[parts[1]] : effectiveOutputs(workflow.steps[producer.get(root) ?? ""] ?? {})[root];
|
|
56
|
+
const shape = referenceShape(workflow, ref);
|
|
57
|
+
const item = { id: ref, name: label(parts.at(-1)), description: definition?.description ?? "The time this run started.", kind: root === "environment" ? `${definition?.type} connection` : typeof shape === "string" ? shape : shape?.type ?? "connection", ...(shape ? { shape } : {}), createdBy: producer.has(root) ? [producer.get(root)] : [], usedBy: [], checkedBy: [], changedBy: [] };
|
|
58
|
+
items.set(ref, item);
|
|
59
|
+
return item;
|
|
60
|
+
}
|
|
61
|
+
for (const section of ["inputs", "state", "environment"])
|
|
62
|
+
for (const name of Object.keys(workflow[section] ?? {}))
|
|
63
|
+
itemFor(`${section}.${name}`);
|
|
64
|
+
for (const name of producer.keys())
|
|
65
|
+
itemFor(name);
|
|
66
|
+
for (const [id, step] of Object.entries(workflow.steps)) {
|
|
67
|
+
for (const ref of references(step)) {
|
|
68
|
+
const item = itemFor(ref);
|
|
69
|
+
item.usedBy.push(id);
|
|
70
|
+
if (step.check)
|
|
71
|
+
item.checkedBy.push(id);
|
|
72
|
+
}
|
|
73
|
+
for (const name of Object.keys(effectiveOutputs(step)))
|
|
74
|
+
if (step.check)
|
|
75
|
+
itemFor(name).checkedBy.push(id);
|
|
76
|
+
for (const target of step.changes ?? []) {
|
|
77
|
+
itemFor(target).changedBy.push(id);
|
|
78
|
+
if (step.check)
|
|
79
|
+
itemFor(target).checkedBy.push(id);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const item of items.values()) {
|
|
83
|
+
item.usedBy = [...new Set(item.usedBy)];
|
|
84
|
+
item.checkedBy = [...new Set(item.checkedBy)];
|
|
85
|
+
item.changedBy = [...new Set(item.changedBy)];
|
|
86
|
+
}
|
|
87
|
+
return { items, itemFor };
|
|
88
|
+
}
|
|
89
|
+
export function copyInstructions(step, inputs, resources) {
|
|
90
|
+
return [executionText(step), inputs ? `Inputs:\n${JSON.stringify(inputs, null, 2)}` : `Supply these named inputs before running:\n${JSON.stringify({ ...step.in, ...step.each }, null, 2)}`, `Return:\n${JSON.stringify(effectiveOutputs(step), null, 2)}`, ...(resources ? [`Connections:\n${JSON.stringify(resources, null, 2)}`] : [])].join("\n\n");
|
|
91
|
+
}
|
|
92
|
+
export function observedValue(item, inspection, invocation) {
|
|
93
|
+
const [root, ...parts] = item.id.split(".");
|
|
94
|
+
let value;
|
|
95
|
+
if (root === "inputs")
|
|
96
|
+
value = inspection.inputs;
|
|
97
|
+
else if (root === "state")
|
|
98
|
+
value = inspection.state;
|
|
99
|
+
else if (root === "environment")
|
|
100
|
+
value = inspection.resources;
|
|
101
|
+
else {
|
|
102
|
+
const rows = Object.entries(inspection.invocations).filter(([id, row]) => item.createdBy.includes(row.step_id) && (!invocation || id === invocation));
|
|
103
|
+
if (!rows.length)
|
|
104
|
+
return undefined;
|
|
105
|
+
value = rows.length === 1 ? rows[0][1].outputs?.[root] : rows.map(([, row]) => row.outputs?.[root] ?? null);
|
|
106
|
+
}
|
|
107
|
+
for (const part of parts) {
|
|
108
|
+
if (!value || !Object.hasOwn(value, part))
|
|
109
|
+
return undefined;
|
|
110
|
+
value = value[part];
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The device form of a run record (run_data: device). Keep step status, kinds, names, and timing., kinds, names, and timing. Remove inputs, outputs,
|
|
116
|
+
* prompts, files, and free text. The server accepts only this form when an organization keeps run content on devices.
|
|
117
|
+
*/
|
|
118
|
+
export function deviceOnly(inspection) {
|
|
119
|
+
const event = ({ at, type, sequence, phase, duration_ms, usage, provider, model, kind, exit_code }) => Object.fromEntries(Object.entries({ at, type, sequence, phase, duration_ms, usage, provider, model, kind, exit_code }).filter(([, value]) => value !== undefined));
|
|
120
|
+
return {
|
|
121
|
+
schema: inspection.schema, content: 'device', workflow: inspection.workflow, run_id: inspection.run_id, status: inspection.status,
|
|
122
|
+
...(inspection.started_at ? { started_at: inspection.started_at } : {}), ...(inspection.device_name ? { device_name: inspection.device_name } : {}),
|
|
123
|
+
inputs: {}, resources: Object.fromEntries(Object.entries(inspection.resources).map(([name, value]) => [name, { description: value.description }])),
|
|
124
|
+
...(inspection.events ? { events: inspection.events.map(event) } : {}),
|
|
125
|
+
invocations: Object.fromEntries(Object.entries(inspection.invocations).map(([id, value]) => [id, {
|
|
126
|
+
step_id: value.step_id, status: value.status, ...(value.verification ? { verification: value.verification } : {}),
|
|
127
|
+
checks: value.checks.map(check => ({ id: check.id, result: check.result, summary: '', evidence: [], method: check.method })), changes: {}, events: value.events.map(event),
|
|
128
|
+
}])),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const MAX_RESULT_FILES = 20000;
|
|
3
|
+
export declare const MAX_RESULT_BYTES = 100000000;
|
|
4
|
+
export declare const MAX_RESULT_TRANSFER_BYTES = 20000000;
|
|
5
|
+
export declare const ResultPathSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
export declare const WebsiteFileSchema: z.ZodObject<{
|
|
7
|
+
path: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
+
sha256: z.ZodString;
|
|
9
|
+
media_type: z.ZodString;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
sha256: string;
|
|
12
|
+
path: string;
|
|
13
|
+
media_type: string;
|
|
14
|
+
}, {
|
|
15
|
+
sha256: string;
|
|
16
|
+
path: string;
|
|
17
|
+
media_type: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** A declared file output with format: method-website contains this manifest. */
|
|
20
|
+
export declare const WebsiteManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
21
|
+
schema: z.ZodLiteral<"method-website/1">;
|
|
22
|
+
title: z.ZodString;
|
|
23
|
+
entrypoint: z.ZodEffects<z.ZodString, string, string>;
|
|
24
|
+
files: z.ZodArray<z.ZodObject<{
|
|
25
|
+
path: z.ZodEffects<z.ZodString, string, string>;
|
|
26
|
+
sha256: z.ZodString;
|
|
27
|
+
media_type: z.ZodString;
|
|
28
|
+
}, "strict", z.ZodTypeAny, {
|
|
29
|
+
sha256: string;
|
|
30
|
+
path: string;
|
|
31
|
+
media_type: string;
|
|
32
|
+
}, {
|
|
33
|
+
sha256: string;
|
|
34
|
+
path: string;
|
|
35
|
+
media_type: string;
|
|
36
|
+
}>, "many">;
|
|
37
|
+
}, "strict", z.ZodTypeAny, {
|
|
38
|
+
files: {
|
|
39
|
+
sha256: string;
|
|
40
|
+
path: string;
|
|
41
|
+
media_type: string;
|
|
42
|
+
}[];
|
|
43
|
+
schema: "method-website/1";
|
|
44
|
+
title: string;
|
|
45
|
+
entrypoint: string;
|
|
46
|
+
}, {
|
|
47
|
+
files: {
|
|
48
|
+
sha256: string;
|
|
49
|
+
path: string;
|
|
50
|
+
media_type: string;
|
|
51
|
+
}[];
|
|
52
|
+
schema: "method-website/1";
|
|
53
|
+
title: string;
|
|
54
|
+
entrypoint: string;
|
|
55
|
+
}>, {
|
|
56
|
+
files: {
|
|
57
|
+
sha256: string;
|
|
58
|
+
path: string;
|
|
59
|
+
media_type: string;
|
|
60
|
+
}[];
|
|
61
|
+
schema: "method-website/1";
|
|
62
|
+
title: string;
|
|
63
|
+
entrypoint: string;
|
|
64
|
+
}, {
|
|
65
|
+
files: {
|
|
66
|
+
sha256: string;
|
|
67
|
+
path: string;
|
|
68
|
+
media_type: string;
|
|
69
|
+
}[];
|
|
70
|
+
schema: "method-website/1";
|
|
71
|
+
title: string;
|
|
72
|
+
entrypoint: string;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const AttachedFileSchema: z.ZodObject<{
|
|
75
|
+
path: z.ZodString;
|
|
76
|
+
sha256: z.ZodString;
|
|
77
|
+
status: z.ZodEnum<["verified", "unavailable"]>;
|
|
78
|
+
observed_at: z.ZodString;
|
|
79
|
+
text: z.ZodOptional<z.ZodString>;
|
|
80
|
+
bytes: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
82
|
+
title: z.ZodOptional<z.ZodString>;
|
|
83
|
+
media_type: z.ZodOptional<z.ZodString>;
|
|
84
|
+
data: z.ZodOptional<z.ZodString>;
|
|
85
|
+
encoding: z.ZodOptional<z.ZodLiteral<"gzip">>;
|
|
86
|
+
stored: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
website: z.ZodOptional<z.ZodObject<{
|
|
88
|
+
entrypoint: z.ZodString;
|
|
89
|
+
files: z.ZodArray<z.ZodObject<{
|
|
90
|
+
path: z.ZodString;
|
|
91
|
+
sha256: z.ZodString;
|
|
92
|
+
media_type: z.ZodString;
|
|
93
|
+
}, "strict", z.ZodTypeAny, {
|
|
94
|
+
sha256: string;
|
|
95
|
+
path: string;
|
|
96
|
+
media_type: string;
|
|
97
|
+
}, {
|
|
98
|
+
sha256: string;
|
|
99
|
+
path: string;
|
|
100
|
+
media_type: string;
|
|
101
|
+
}>, "many">;
|
|
102
|
+
}, "strict", z.ZodTypeAny, {
|
|
103
|
+
files: {
|
|
104
|
+
sha256: string;
|
|
105
|
+
path: string;
|
|
106
|
+
media_type: string;
|
|
107
|
+
}[];
|
|
108
|
+
entrypoint: string;
|
|
109
|
+
}, {
|
|
110
|
+
files: {
|
|
111
|
+
sha256: string;
|
|
112
|
+
path: string;
|
|
113
|
+
media_type: string;
|
|
114
|
+
}[];
|
|
115
|
+
entrypoint: string;
|
|
116
|
+
}>>;
|
|
117
|
+
}, "strict", z.ZodTypeAny, {
|
|
118
|
+
sha256: string;
|
|
119
|
+
status: "verified" | "unavailable";
|
|
120
|
+
path: string;
|
|
121
|
+
observed_at: string;
|
|
122
|
+
text?: string | undefined;
|
|
123
|
+
bytes?: number | undefined;
|
|
124
|
+
encoding?: "gzip" | undefined;
|
|
125
|
+
media_type?: string | undefined;
|
|
126
|
+
title?: string | undefined;
|
|
127
|
+
reason?: string | undefined;
|
|
128
|
+
data?: string | undefined;
|
|
129
|
+
stored?: boolean | undefined;
|
|
130
|
+
website?: {
|
|
131
|
+
files: {
|
|
132
|
+
sha256: string;
|
|
133
|
+
path: string;
|
|
134
|
+
media_type: string;
|
|
135
|
+
}[];
|
|
136
|
+
entrypoint: string;
|
|
137
|
+
} | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
sha256: string;
|
|
140
|
+
status: "verified" | "unavailable";
|
|
141
|
+
path: string;
|
|
142
|
+
observed_at: string;
|
|
143
|
+
text?: string | undefined;
|
|
144
|
+
bytes?: number | undefined;
|
|
145
|
+
encoding?: "gzip" | undefined;
|
|
146
|
+
media_type?: string | undefined;
|
|
147
|
+
title?: string | undefined;
|
|
148
|
+
reason?: string | undefined;
|
|
149
|
+
data?: string | undefined;
|
|
150
|
+
stored?: boolean | undefined;
|
|
151
|
+
website?: {
|
|
152
|
+
files: {
|
|
153
|
+
sha256: string;
|
|
154
|
+
path: string;
|
|
155
|
+
media_type: string;
|
|
156
|
+
}[];
|
|
157
|
+
entrypoint: string;
|
|
158
|
+
} | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
export type AttachedFile = z.infer<typeof AttachedFileSchema>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Bound both decoded content and compressed transfer size.
|
|
3
|
+
export const MAX_RESULT_FILES = 20_000;
|
|
4
|
+
export const MAX_RESULT_BYTES = 100_000_000;
|
|
5
|
+
export const MAX_RESULT_TRANSFER_BYTES = 20_000_000;
|
|
6
|
+
const hash = z.string().regex(/^[a-f0-9]{64}$/);
|
|
7
|
+
export const ResultPathSchema = z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(500)
|
|
11
|
+
.refine((path) => !path.startsWith("/") &&
|
|
12
|
+
!path.includes("\\") &&
|
|
13
|
+
!path
|
|
14
|
+
.split("/")
|
|
15
|
+
.some((part) => !part || part === "." || part === "..") &&
|
|
16
|
+
!/[?#%\x00-\x1f]/.test(path), "Use a relative file path without parent directories.");
|
|
17
|
+
export const WebsiteFileSchema = z.strictObject({
|
|
18
|
+
path: ResultPathSchema,
|
|
19
|
+
sha256: hash,
|
|
20
|
+
media_type: z.string().regex(/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/),
|
|
21
|
+
});
|
|
22
|
+
/** A declared file output with format: method-website contains this manifest. */
|
|
23
|
+
export const WebsiteManifestSchema = z
|
|
24
|
+
.strictObject({
|
|
25
|
+
schema: z.literal("method-website/1"),
|
|
26
|
+
title: z.string().min(1).max(160),
|
|
27
|
+
entrypoint: ResultPathSchema,
|
|
28
|
+
files: z.array(WebsiteFileSchema).min(1).max(MAX_RESULT_FILES),
|
|
29
|
+
})
|
|
30
|
+
.superRefine((value, ctx) => {
|
|
31
|
+
if (new Set(value.files.map((file) => file.path)).size !== value.files.length)
|
|
32
|
+
ctx.addIssue({
|
|
33
|
+
code: "custom",
|
|
34
|
+
message: "Website paths must be unique.",
|
|
35
|
+
});
|
|
36
|
+
if (!value.files.some((file) => file.path === value.entrypoint && file.media_type === "text/html"))
|
|
37
|
+
ctx.addIssue({
|
|
38
|
+
code: "custom",
|
|
39
|
+
message: "The start page must be an HTML file in the file list.",
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
export const AttachedFileSchema = z.strictObject({
|
|
43
|
+
path: z.string(),
|
|
44
|
+
sha256: z.string(),
|
|
45
|
+
status: z.enum(["verified", "unavailable"]),
|
|
46
|
+
observed_at: z.string(),
|
|
47
|
+
text: z.string().optional(),
|
|
48
|
+
bytes: z.number().optional(),
|
|
49
|
+
reason: z.string().optional(),
|
|
50
|
+
title: z.string().max(160).optional(),
|
|
51
|
+
media_type: z.string().optional(),
|
|
52
|
+
data: z.string().max(MAX_RESULT_TRANSFER_BYTES * 4 / 3).optional(),
|
|
53
|
+
encoding: z.literal("gzip").optional(),
|
|
54
|
+
stored: z.boolean().optional(),
|
|
55
|
+
website: z
|
|
56
|
+
.strictObject({
|
|
57
|
+
entrypoint: z.string(),
|
|
58
|
+
files: z
|
|
59
|
+
.array(z.strictObject({
|
|
60
|
+
path: z.string(),
|
|
61
|
+
sha256: hash,
|
|
62
|
+
media_type: z.string(),
|
|
63
|
+
}))
|
|
64
|
+
.max(MAX_RESULT_FILES),
|
|
65
|
+
})
|
|
66
|
+
.optional(),
|
|
67
|
+
});
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
3
|
+
[key: string]: Json;
|
|
4
|
+
};
|
|
5
|
+
export declare const JsonSchema: z.ZodType<Json>;
|
|
6
|
+
export declare const NameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
7
|
+
export declare const ReferenceSchema: z.ZodString;
|
|
8
|
+
export declare const TypeSchema: z.ZodEnum<["text", "number", "boolean", "record", "list", "file"]>;
|
|
9
|
+
export type ValueType = z.infer<typeof TypeSchema>;
|
|
10
|
+
export type Shape = ValueType | {
|
|
11
|
+
type: ValueType;
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
fields?: Record<string, Shape> | undefined;
|
|
14
|
+
items?: Shape | undefined;
|
|
15
|
+
format?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
export declare const ShapeSchema: z.ZodType<Shape>;
|
|
18
|
+
export declare const DataSchema: z.ZodObject<{
|
|
19
|
+
type: z.ZodEnum<["text", "number", "boolean", "record", "list", "file"]>;
|
|
20
|
+
description: z.ZodOptional<z.ZodString>;
|
|
21
|
+
fields: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodType<Shape, z.ZodTypeDef, Shape>>>;
|
|
22
|
+
items: z.ZodOptional<z.ZodType<Shape, z.ZodTypeDef, Shape>>;
|
|
23
|
+
format: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strict", z.ZodTypeAny, {
|
|
25
|
+
type: "number" | "boolean" | "file" | "text" | "record" | "list";
|
|
26
|
+
description?: string | undefined;
|
|
27
|
+
fields?: Record<string, Shape> | undefined;
|
|
28
|
+
items?: Shape | undefined;
|
|
29
|
+
format?: string | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
type: "number" | "boolean" | "file" | "text" | "record" | "list";
|
|
32
|
+
description?: string | undefined;
|
|
33
|
+
fields?: Record<string, Shape> | undefined;
|
|
34
|
+
items?: Shape | undefined;
|
|
35
|
+
format?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const InputSchema: z.ZodObject<{
|
|
38
|
+
type: z.ZodEnum<["text", "number", "boolean", "record", "list", "file"]>;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
fields: z.ZodOptional<z.ZodRecord<z.ZodEffects<z.ZodString, string, string>, z.ZodType<Shape, z.ZodTypeDef, Shape>>>;
|
|
41
|
+
items: z.ZodOptional<z.ZodType<Shape, z.ZodTypeDef, Shape>>;
|
|
42
|
+
format: z.ZodOptional<z.ZodString>;
|
|
43
|
+
} & {
|
|
44
|
+
default: z.ZodOptional<z.ZodType<Json, z.ZodTypeDef, Json>>;
|
|
45
|
+
}, "strict", z.ZodTypeAny, {
|
|
46
|
+
type: "number" | "boolean" | "file" | "text" | "record" | "list";
|
|
47
|
+
default?: Json | undefined;
|
|
48
|
+
description?: string | undefined;
|
|
49
|
+
fields?: Record<string, Shape> | undefined;
|
|
50
|
+
items?: Shape | undefined;
|
|
51
|
+
format?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
type: "number" | "boolean" | "file" | "text" | "record" | "list";
|
|
54
|
+
default?: Json | undefined;
|
|
55
|
+
description?: string | undefined;
|
|
56
|
+
fields?: Record<string, Shape> | undefined;
|
|
57
|
+
items?: Shape | undefined;
|
|
58
|
+
format?: string | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
export declare const EnvironmentSchema: z.ZodObject<{
|
|
61
|
+
type: z.ZodEnum<["browser", "service", "desktop", "files", "tool"]>;
|
|
62
|
+
description: z.ZodString;
|
|
63
|
+
role: z.ZodOptional<z.ZodLiteral<"observer">>;
|
|
64
|
+
}, "strict", z.ZodTypeAny, {
|
|
65
|
+
type: "browser" | "service" | "desktop" | "files" | "tool";
|
|
66
|
+
description: string;
|
|
67
|
+
role?: "observer" | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
type: "browser" | "service" | "desktop" | "files" | "tool";
|
|
70
|
+
description: string;
|
|
71
|
+
role?: "observer" | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
export type ExactCheck = {
|
|
74
|
+
equals: {
|
|
75
|
+
actual: string;
|
|
76
|
+
expected: string;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
count: {
|
|
80
|
+
value: string;
|
|
81
|
+
min?: number;
|
|
82
|
+
max?: number;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
present: string;
|
|
86
|
+
} | {
|
|
87
|
+
file: string;
|
|
88
|
+
};
|
|
89
|
+
export type BaseStep = {
|
|
90
|
+
name?: string;
|
|
91
|
+
in?: Record<string, string>;
|
|
92
|
+
ask?: string;
|
|
93
|
+
out?: string | Record<string, z.infer<typeof DataSchema>>;
|
|
94
|
+
each?: Record<string, string>;
|
|
95
|
+
when?: string;
|
|
96
|
+
after?: string | string[];
|
|
97
|
+
changes?: string[];
|
|
98
|
+
};
|
|
99
|
+
export type DataDefinition = z.infer<typeof DataSchema>;
|
|
100
|
+
export declare const FileArtifactSchema: z.ZodObject<{
|
|
101
|
+
path: z.ZodString;
|
|
102
|
+
sha256: z.ZodString;
|
|
103
|
+
}, "strict", z.ZodTypeAny, {
|
|
104
|
+
sha256: string;
|
|
105
|
+
path: string;
|
|
106
|
+
}, {
|
|
107
|
+
sha256: string;
|
|
108
|
+
path: string;
|
|
109
|
+
}>;
|
|
110
|
+
/** JSON Pointer remains a private editing/JSON utility, never a workflow binding. */
|
|
111
|
+
export declare function pointer(value: Json | undefined, path: string): Json | undefined;
|
|
112
|
+
export type RunExecution = {
|
|
113
|
+
kind: "run";
|
|
114
|
+
runtime: string;
|
|
115
|
+
entrypoint: string;
|
|
116
|
+
args?: string[];
|
|
117
|
+
};
|
|
118
|
+
export type AgentExecution = {
|
|
119
|
+
kind: "agent";
|
|
120
|
+
model: string;
|
|
121
|
+
prompt: string;
|
|
122
|
+
tools?: string[];
|
|
123
|
+
browser?: string;
|
|
124
|
+
};
|
|
125
|
+
/** Exactly one answer form: options (a choice), answer: "yes_no", or levels (2-10 ordered names, lowest first). */
|
|
126
|
+
export type ClassifyExecution = {
|
|
127
|
+
kind: "classify";
|
|
128
|
+
question: string;
|
|
129
|
+
options?: Record<string, string>;
|
|
130
|
+
answer?: "yes_no";
|
|
131
|
+
levels?: string[];
|
|
132
|
+
};
|
|
133
|
+
export type Execution = ClassifyExecution | RunExecution | AgentExecution | {
|
|
134
|
+
kind: "call";
|
|
135
|
+
model: string;
|
|
136
|
+
prompt: string;
|
|
137
|
+
};
|
|
138
|
+
export type CurrentCheck = ExactCheck | RunExecution | AgentExecution;
|
|
139
|
+
/** An effect contract: an observer confirms an external change; the action's receipt never does. */
|
|
140
|
+
export type Effect = {
|
|
141
|
+
intent: string;
|
|
142
|
+
in?: Record<string, string>;
|
|
143
|
+
observe: RunExecution;
|
|
144
|
+
judge: RunExecution;
|
|
145
|
+
fixtures: string;
|
|
146
|
+
schedule: {
|
|
147
|
+
first?: string;
|
|
148
|
+
then?: string[];
|
|
149
|
+
horizon: string;
|
|
150
|
+
};
|
|
151
|
+
confirm: "positive" | "unrefuted_at_horizon";
|
|
152
|
+
retry?: "never" | "idempotent";
|
|
153
|
+
blocking?: boolean;
|
|
154
|
+
};
|
|
155
|
+
export type CurrentStep = BaseStep & {
|
|
156
|
+
purpose?: string;
|
|
157
|
+
do?: Execution;
|
|
158
|
+
check?: CurrentCheck;
|
|
159
|
+
effects?: Record<string, Effect>;
|
|
160
|
+
reading?: {
|
|
161
|
+
inputs?: string;
|
|
162
|
+
outputs?: string;
|
|
163
|
+
output_name?: string;
|
|
164
|
+
condition?: string;
|
|
165
|
+
check?: string;
|
|
166
|
+
check_name?: string;
|
|
167
|
+
};
|
|
168
|
+
repeat?: {
|
|
169
|
+
max_iterations: number;
|
|
170
|
+
until?: string;
|
|
171
|
+
};
|
|
172
|
+
limits?: {
|
|
173
|
+
timeout_ms?: number;
|
|
174
|
+
max_agent_turns?: number;
|
|
175
|
+
max_model_requests?: number;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export type CurrentWorkflow = {
|
|
179
|
+
name: string;
|
|
180
|
+
goal: string;
|
|
181
|
+
inputs?: Record<string, z.infer<typeof InputSchema>>;
|
|
182
|
+
environment?: Record<string, z.infer<typeof EnvironmentSchema>>;
|
|
183
|
+
result: string | Record<string, string>;
|
|
184
|
+
format: "method/3.1" | "method/3.2" | "method/3.3" | "method/3.4";
|
|
185
|
+
id?: string;
|
|
186
|
+
models?: Record<string, string | {
|
|
187
|
+
model: string;
|
|
188
|
+
max_output_tokens?: number;
|
|
189
|
+
reasoning_effort?: string;
|
|
190
|
+
}>;
|
|
191
|
+
run_prompt?: string;
|
|
192
|
+
run_label?: string;
|
|
193
|
+
files?: string[];
|
|
194
|
+
state?: Record<string, z.infer<typeof InputSchema>>;
|
|
195
|
+
steps: Record<string, CurrentStep>;
|
|
196
|
+
};
|
|
197
|
+
export declare const CurrentStepSchema: z.ZodType<CurrentStep, z.ZodTypeDef, CurrentStep>;
|
|
198
|
+
export declare const CurrentCheckSchema: z.ZodType<CurrentCheck, z.ZodTypeDef, CurrentCheck>;
|
|
199
|
+
export declare const CurrentWorkflowSchema: z.ZodType<CurrentWorkflow, z.ZodTypeDef, CurrentWorkflow>;
|
|
200
|
+
export declare const WorkflowSchema: z.ZodType<CurrentWorkflow, z.ZodTypeDef, CurrentWorkflow>;
|
|
201
|
+
export type Workflow = z.infer<typeof WorkflowSchema>;
|
|
202
|
+
export type Step = Workflow["steps"][string];
|
|
203
|
+
export type Check = NonNullable<Step["check"]>;
|
|
204
|
+
export declare function executionText(step: Step): string;
|
|
205
|
+
export declare function executionLabel(step: Step): string;
|
|
206
|
+
export declare function effectiveOutputs(step: Step): Record<string, DataDefinition>;
|
|
207
|
+
export declare function executionCommand(execution: RunExecution): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const JsonSchema = z.lazy(() => z.union([z.null(), z.boolean(), z.number().finite(), z.string(), z.array(JsonSchema), z.record(JsonSchema)]));
|
|
3
|
+
export const NameSchema = z.string().regex(/^[a-z][a-z0-9_]*$/).max(80).refine(name => !["constructor", "prototype", "__proto__"].includes(name), "Reserved name.");
|
|
4
|
+
export const ReferenceSchema = z.string().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*|\.[0-9]+)*$/);
|
|
5
|
+
const Text = z.string().trim().min(1).max(16000);
|
|
6
|
+
export const TypeSchema = z.enum(["text", "number", "boolean", "record", "list", "file"]);
|
|
7
|
+
export const ShapeSchema = z.lazy(() => z.union([TypeSchema, z.strictObject({ type: TypeSchema, description: Text.optional(), fields: z.record(NameSchema, ShapeSchema).optional(), items: ShapeSchema.optional(), format: Text.optional() })]));
|
|
8
|
+
export const DataSchema = z.strictObject({ type: TypeSchema, description: Text.optional(), fields: z.record(NameSchema, ShapeSchema).optional(), items: ShapeSchema.optional(), format: Text.optional() });
|
|
9
|
+
export const InputSchema = DataSchema.extend({ default: JsonSchema.optional() });
|
|
10
|
+
export const EnvironmentSchema = z.strictObject({ type: z.enum(["browser", "service", "desktop", "files", "tool"]), description: Text, role: z.literal("observer").optional() });
|
|
11
|
+
export const FileArtifactSchema = z.strictObject({ path: z.string().min(1), sha256: z.string().regex(/^[a-f0-9]{64}$/) });
|
|
12
|
+
/** JSON Pointer remains a private editing/JSON utility, never a workflow binding. */
|
|
13
|
+
export function pointer(value, path) {
|
|
14
|
+
if (path === "")
|
|
15
|
+
return value;
|
|
16
|
+
if (!/^(?:\/(?:[^~]|~[01])*)*$/.test(path))
|
|
17
|
+
throw Error("Invalid JSON Pointer.");
|
|
18
|
+
let current = value;
|
|
19
|
+
for (const segment of path.slice(1).split("/")) {
|
|
20
|
+
const key = segment.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
21
|
+
if (!current || typeof current !== "object" || !Object.hasOwn(current, key))
|
|
22
|
+
return undefined;
|
|
23
|
+
if (Array.isArray(current) && !/^(0|[1-9][0-9]*)$/.test(key))
|
|
24
|
+
return undefined;
|
|
25
|
+
current = current[key];
|
|
26
|
+
}
|
|
27
|
+
return current;
|
|
28
|
+
}
|
|
29
|
+
// Current shape validation comes from the runtime's single JSON Schema.
|
|
30
|
+
import { methodShape, stepShape, checkShape } from "@withmethod/runtime/document-validators.js";
|
|
31
|
+
function currentShape(validate) {
|
|
32
|
+
return z.any().superRefine((value, context) => {
|
|
33
|
+
if (!validate(value))
|
|
34
|
+
for (const error of validate.errors ?? [])
|
|
35
|
+
context.addIssue({
|
|
36
|
+
code: z.ZodIssueCode.custom, message: `${error.instancePath || "/"}: ${error.message}`,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export const CurrentStepSchema = currentShape(stepShape);
|
|
41
|
+
export const CurrentCheckSchema = currentShape(checkShape);
|
|
42
|
+
export const CurrentWorkflowSchema = currentShape(methodShape);
|
|
43
|
+
export const WorkflowSchema = CurrentWorkflowSchema;
|
|
44
|
+
export function executionText(step) {
|
|
45
|
+
if (!step.do)
|
|
46
|
+
return step.ask ?? "";
|
|
47
|
+
return step.do.kind === "run" ? (step.purpose ?? "No script description was recorded.") : step.do.kind === "classify" ? step.do.question : step.do.prompt;
|
|
48
|
+
}
|
|
49
|
+
export function executionLabel(step) {
|
|
50
|
+
return step.ask ? "Human input" : typeof step.do === "object" ? ({ run: "Script", call: "Model call", agent: "Agent", classify: "Classification" }[step.do.kind]) : "Agent";
|
|
51
|
+
}
|
|
52
|
+
import { effectiveOutputs as runtimeOutputs } from '@withmethod/runtime/semantics.js';
|
|
53
|
+
export function effectiveOutputs(step) { return runtimeOutputs(step); }
|
|
54
|
+
export function executionCommand(execution) {
|
|
55
|
+
return [execution.runtime, execution.entrypoint, ...(execution.args ?? [])].join(' ');
|
|
56
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { parseDocumentValue, shapeErrors, MethodValidationError } from '@withmethod/runtime/document.js';
|
|
2
|
+
export { outputSchema } from '@withmethod/runtime/semantics.js';
|
|
3
|
+
import { type Workflow, type Step, type Shape } from "./schema.js";
|
|
4
|
+
export declare function serializeWorkflow(value: unknown): string;
|
|
5
|
+
export declare function shapeObject(shape: Shape): Exclude<Shape, string>;
|
|
6
|
+
export declare function validateShape(shape: Shape, label: string): void;
|
|
7
|
+
export declare function references(step: Step): string[];
|
|
8
|
+
export declare function producers(workflow: Workflow): Map<string, string>;
|
|
9
|
+
export declare function referenceShape(workflow: Workflow, reference: string): Shape | undefined;
|
|
10
|
+
export declare function stepDependencies(workflow: Workflow, id: string): string[];
|
|
11
|
+
export declare function loadWorkflow(value: unknown): Workflow;
|