@a5c-ai/babysitter-sdk 5.0.1-staging.75c8fb21 → 5.0.1-staging.7a765939
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.
|
@@ -5,5 +5,33 @@ export interface DefineTaskOptions {
|
|
|
5
5
|
kind?: string;
|
|
6
6
|
source?: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Backward-compatible single-object form accepted by defineTask.
|
|
10
|
+
* Two flavors are recognized:
|
|
11
|
+
* 1. Static TaskDef shape: { id|name, kind, title, labels, ...rest } — the
|
|
12
|
+
* whole object (minus id/name/run/source/inputs/outputs) is treated as a
|
|
13
|
+
* static TaskDef returned for every invocation.
|
|
14
|
+
* 2. Run-function shape: { id|name, run(args, ctx) -> TaskDef|Promise<TaskDef>,
|
|
15
|
+
* description?, labels?, kind?, source?, inputs?, outputs? } — `run` is
|
|
16
|
+
* used as the impl. `inputs`/`outputs` schemas are stored as metadata for
|
|
17
|
+
* tooling but are not enforced at runtime.
|
|
18
|
+
*
|
|
19
|
+
* This shape is used by ~75 library/contrib and library/methodologies files
|
|
20
|
+
* authored against an earlier SDK API; supporting it here keeps those processes
|
|
21
|
+
* runnable without per-file rewrites.
|
|
22
|
+
*/
|
|
23
|
+
export interface DefineTaskObjectSpec<TArgs = unknown, TResult = unknown> {
|
|
24
|
+
id?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
labels?: string[];
|
|
28
|
+
kind?: string;
|
|
29
|
+
source?: string;
|
|
30
|
+
run?: TaskImpl<TArgs, TResult>;
|
|
31
|
+
inputs?: Record<string, unknown>;
|
|
32
|
+
outputs?: Record<string, unknown>;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
8
35
|
export declare function defineTask<TArgs = unknown, TResult = unknown>(id: string, impl: TaskImpl<TArgs, TResult>, options?: DefineTaskOptions): DefinedTask<TArgs, TResult>;
|
|
36
|
+
export declare function defineTask<TArgs = unknown, TResult = unknown>(spec: DefineTaskObjectSpec<TArgs, TResult>): DefinedTask<TArgs, TResult>;
|
|
9
37
|
//# sourceMappingURL=defineTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineTask.d.ts","sourceRoot":"","sources":["../../src/tasks/defineTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA6B,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC3D,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,EAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"defineTask.d.ts","sourceRoot":"","sources":["../../src/tasks/defineTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA6B,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,oBAAoB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IACtE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC3D,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC/B,wBAAgB,UAAU,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC3D,IAAI,EAAE,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,GACzC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC"}
|
package/dist/tasks/defineTask.js
CHANGED
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineTask = defineTask;
|
|
4
4
|
const registry_1 = require("./registry");
|
|
5
|
-
function defineTask(
|
|
5
|
+
function defineTask(idOrSpec, maybeImpl, maybeOptions = {}) {
|
|
6
|
+
// Object-form dispatch: defineTask({ id|name, ..., run? })
|
|
7
|
+
if (typeof idOrSpec === "object" && idOrSpec !== null) {
|
|
8
|
+
return defineTaskFromObject(idOrSpec);
|
|
9
|
+
}
|
|
10
|
+
const id = idOrSpec;
|
|
11
|
+
const impl = maybeImpl;
|
|
12
|
+
const options = maybeOptions;
|
|
13
|
+
if (typeof impl !== "function") {
|
|
14
|
+
throw new Error("defineTask positional form requires (id, impl) where impl is a function returning a TaskDef");
|
|
15
|
+
}
|
|
6
16
|
const taskId = normalizeTaskId(id);
|
|
7
17
|
registerTaskId(taskId, options);
|
|
8
18
|
const defined = {
|
|
@@ -44,6 +54,37 @@ function normalizeTaskId(id) {
|
|
|
44
54
|
}
|
|
45
55
|
return id.trim();
|
|
46
56
|
}
|
|
57
|
+
function defineTaskFromObject(spec) {
|
|
58
|
+
const taskId = spec.id ?? spec.name;
|
|
59
|
+
if (typeof taskId !== "string" || !taskId.trim()) {
|
|
60
|
+
throw new Error("defineTask object form requires a non-empty `id` or `name` string");
|
|
61
|
+
}
|
|
62
|
+
const options = {
|
|
63
|
+
description: spec.description,
|
|
64
|
+
labels: spec.labels,
|
|
65
|
+
kind: spec.kind,
|
|
66
|
+
source: spec.source,
|
|
67
|
+
};
|
|
68
|
+
let impl;
|
|
69
|
+
if (typeof spec.run === "function") {
|
|
70
|
+
// Flavor (2): defineTask({ id|name, run, ... })
|
|
71
|
+
impl = spec.run;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// Flavor (1): static TaskDef. Everything except SDK-recognized envelope
|
|
75
|
+
// fields becomes the static TaskDef.
|
|
76
|
+
const { id: _id, name: _name, run: _run, inputs: _inputs, outputs: _outputs, source: _source, ...rest } = spec;
|
|
77
|
+
void _id;
|
|
78
|
+
void _name;
|
|
79
|
+
void _run;
|
|
80
|
+
void _inputs;
|
|
81
|
+
void _outputs;
|
|
82
|
+
void _source;
|
|
83
|
+
const staticTaskDef = rest;
|
|
84
|
+
impl = (() => staticTaskDef);
|
|
85
|
+
}
|
|
86
|
+
return defineTask(taskId, impl, options);
|
|
87
|
+
}
|
|
47
88
|
function normalizeTaskDef(taskDef) {
|
|
48
89
|
if (!taskDef || typeof taskDef !== "object") {
|
|
49
90
|
throw new Error("Task implementations must return a TaskDef object");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a5c-ai/babysitter-sdk",
|
|
3
|
-
"version": "5.0.1-staging.
|
|
3
|
+
"version": "5.0.1-staging.7a765939",
|
|
4
4
|
"description": "Storage and run-registry primitives for event-sourced babysitter workflows.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"smoke:cli": "node scripts/smoke-cli.js --runs-dir packages/sdk/test-fixtures/cli/runs/smoke"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@a5c-ai/agent-catalog": "
|
|
43
|
-
"@a5c-ai/agent-mux": "^0.4.10-staging.
|
|
42
|
+
"@a5c-ai/agent-catalog": "5.0.1-staging.7a765939",
|
|
43
|
+
"@a5c-ai/agent-mux": "^0.4.10-staging.7a765939",
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
45
45
|
"@sinclair/typebox": "^0.34.48",
|
|
46
46
|
"zod": "^4.0.0",
|