@trailstep/authoring 0.1.1 → 0.2.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/README.md +72 -19
- package/dist/index.d.ts +1 -14
- package/dist/index.js +25 -18
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Use this package to author continuation workflows with:
|
|
|
17
17
|
- `defineWorkflow({ start })` as the workflow boundary.
|
|
18
18
|
- `step(...)` for focused units of agent or local work.
|
|
19
19
|
- `.prompt(...).do(...)` for agent-backed steps with structured output.
|
|
20
|
+
- `subPrompt(...)` for dispatching typed helper prompts from inside a running step.
|
|
20
21
|
- `done(...)` and `fail(...)` for terminal continuations.
|
|
21
22
|
- `shape(...)` or `jsonSchema(...)` for JSON-object validation.
|
|
22
23
|
- prompt helpers such as `promptSections`, `section`, `loadFragments`, and `promptTemplate`.
|
|
@@ -25,19 +26,56 @@ Use this package to author continuation workflows with:
|
|
|
25
26
|
|
|
26
27
|
Keep workflow entrypoints small and put step logic in separate files as workflows grow.
|
|
27
28
|
|
|
29
|
+
```ts
|
|
30
|
+
// workflows/feature-summary.schema.ts
|
|
31
|
+
import { shape } from "@trailstep/authoring";
|
|
32
|
+
|
|
33
|
+
export type FeatureSummaryInput = {
|
|
34
|
+
readonly request: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type FeatureSummaryOutput = {
|
|
38
|
+
readonly summary: string;
|
|
39
|
+
readonly nextStep: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const featureSummaryInput = shape<FeatureSummaryInput>({
|
|
43
|
+
request: "string",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const featureSummaryOutput = shape<FeatureSummaryOutput>({
|
|
47
|
+
summary: "string",
|
|
48
|
+
nextStep: "string",
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
28
52
|
```ts
|
|
29
53
|
// workflows/feature-summary.workflow.ts
|
|
30
|
-
import { defineWorkflow
|
|
54
|
+
import { defineWorkflow } from "@trailstep/authoring";
|
|
55
|
+
import {
|
|
56
|
+
type FeatureSummaryInput,
|
|
57
|
+
type FeatureSummaryOutput,
|
|
58
|
+
featureSummaryInput,
|
|
59
|
+
featureSummaryOutput,
|
|
60
|
+
} from "./feature-summary.schema.js";
|
|
31
61
|
import { summarizeRequestStep } from "./steps/summarize-request.step.js";
|
|
32
62
|
|
|
33
|
-
type FeatureSummaryInput = { request: string };
|
|
34
|
-
type FeatureSummaryOutput = { summary: string; nextStep: string };
|
|
35
|
-
|
|
36
63
|
export const featureSummary = defineWorkflow<FeatureSummaryInput, FeatureSummaryOutput>({
|
|
37
64
|
id: "feature-summary",
|
|
38
65
|
description: "Summarize a feature request and suggest one next step.",
|
|
39
|
-
|
|
40
|
-
|
|
66
|
+
skill: {
|
|
67
|
+
description: "Use when an agent needs to summarize a feature request.",
|
|
68
|
+
instructions: "Capture the user's request faithfully and recommend one concrete next step.",
|
|
69
|
+
},
|
|
70
|
+
inputShape: featureSummaryInput,
|
|
71
|
+
outputShape: featureSummaryOutput,
|
|
72
|
+
agents: {
|
|
73
|
+
summarizer: {
|
|
74
|
+
size: "medium",
|
|
75
|
+
thinking: "medium",
|
|
76
|
+
description: "Summarizes feature requests for planning.",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
41
79
|
start(input) {
|
|
42
80
|
return summarizeRequestStep(input);
|
|
43
81
|
},
|
|
@@ -46,22 +84,37 @@ export const featureSummary = defineWorkflow<FeatureSummaryInput, FeatureSummary
|
|
|
46
84
|
|
|
47
85
|
```ts
|
|
48
86
|
// workflows/steps/summarize-request.step.ts
|
|
49
|
-
import { done,
|
|
50
|
-
|
|
51
|
-
type FeatureSummaryInput
|
|
52
|
-
type FeatureSummaryOutput
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
87
|
+
import { done, promptSections, section, step } from "@trailstep/authoring";
|
|
88
|
+
import {
|
|
89
|
+
type FeatureSummaryInput,
|
|
90
|
+
type FeatureSummaryOutput,
|
|
91
|
+
featureSummaryOutput,
|
|
92
|
+
} from "../feature-summary.schema.js";
|
|
93
|
+
|
|
94
|
+
function summarizeRequestPrompt({
|
|
95
|
+
input,
|
|
96
|
+
}: {
|
|
97
|
+
readonly input: FeatureSummaryInput;
|
|
98
|
+
}): string {
|
|
99
|
+
return promptSections(
|
|
100
|
+
section("Feature request", input.request),
|
|
101
|
+
section(
|
|
102
|
+
"Task",
|
|
103
|
+
"Summarize the request in two or three sentences, then recommend exactly one next step.",
|
|
104
|
+
),
|
|
105
|
+
);
|
|
62
106
|
}
|
|
107
|
+
|
|
108
|
+
export const summarizeRequestStep = step({ id: "summarize-request" })
|
|
109
|
+
.prompt<FeatureSummaryInput, FeatureSummaryOutput>(summarizeRequestPrompt, {
|
|
110
|
+
agent: "summarizer",
|
|
111
|
+
output: featureSummaryOutput,
|
|
112
|
+
})
|
|
113
|
+
.do((output) => done(output));
|
|
63
114
|
```
|
|
64
115
|
|
|
116
|
+
The optional `skill` block customizes generated agent skill metadata. TrailStep still appends generated CLI usage, input-file, and schema instructions when creating the skill. Raw skill markdown that starts with YAML frontmatter keeps that frontmatter exactly; raw markdown without frontmatter is wrapped in generated `name`/`description` frontmatter before the custom body.
|
|
117
|
+
|
|
65
118
|
Run direct refs while developing:
|
|
66
119
|
|
|
67
120
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { Document, FailNode, PromptOptions, PromptTemplateSource, RetryPolicy, RetryPolicyInput, Schema, ShapeInput, ShapeObject, ShapePrimitive, StepConfig, StepFactory, TimeoutPolicy, TimeoutPolicyInput, Workflow, document, done, fail, jsonSchema, list, loadFragments, promptSections, promptTemplate, section, shape, state, step } from '@trailstep/core';
|
|
3
|
-
|
|
4
|
-
interface WorkflowBuilderOptions<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> extends Workflow<TInput, TOutput> {
|
|
5
|
-
readonly description?: string;
|
|
6
|
-
readonly start: (input: TInput) => ReturnType<NonNullable<Workflow<TInput, TOutput>["start"]>>;
|
|
7
|
-
}
|
|
8
|
-
type DefinedWorkflow<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = Workflow<TInput, TOutput> & {
|
|
9
|
-
readonly description?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
declare function defineWorkflow<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject>(options: WorkflowBuilderOptions<TInput, TOutput>): DefinedWorkflow<TInput, TOutput>;
|
|
13
|
-
|
|
14
|
-
export { type DefinedWorkflow, type WorkflowBuilderOptions, defineWorkflow };
|
|
1
|
+
export { AbsoluteDoneNode, AbsoluteFailNode, CheckWaitCallback, CheckWaitContext, CheckWaitHelpers, ContinuationArray, ContinuationResult, DeepReadonly, DefinedWorkflow, DisplayPhase, DoPhase, Document, FailNode, NotifyApi, NotifyArtifact, ParallelNode, PostContinuation, PromptOptions, PromptPhase, PromptTemplateSource, RetryPolicy, RetryPolicyInput, RunnableContinuationNode, Schema, ShapeInput, ShapeObject, ShapePrimitive, StepConfig, StepContextContinuation, StepContinuationOutput, StepCwdCallback, StepCwdContext, StepCwdInput, StepDisplayCallback, StepDisplayContent, StepDisplayContext, StepDisplayLevel, StepDisplayObject, StepDisplayValue, StepFactory, StepPhase, StepWaitContext, SubPromptFactory, SubPromptOptions, TerminalMessageOptions, TimeoutPolicy, TimeoutPolicyInput, WaitCallback, WaitCheckResult, WaitDefinition, WaitDoneResult, WaitInput, WaitOptions, WaitPendingInput, WaitPendingResult, WaitPhase, Workflow, WorkflowBuilderOptions, WorkflowInputApi, WorkflowInvocationNode, WorkflowInvocationOptions, WorkflowSkillOptions, absoluteDone, absoluteFail, defineWorkflow, document, done, fail, globalState, isAbsoluteDoneNode, isAbsoluteFailNode, isParallelNode, isWorkflowInvocationNode, jsonSchema, list, loadFragments, notify, parallel, promptSections, promptTemplate, section, shape, state, step, subPrompt, workflow } from '@trailstep/core';
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,58 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import {
|
|
3
|
+
absoluteDone,
|
|
4
|
+
absoluteFail,
|
|
3
5
|
Document,
|
|
4
6
|
document,
|
|
5
7
|
done,
|
|
6
8
|
fail,
|
|
9
|
+
globalState,
|
|
10
|
+
isAbsoluteDoneNode,
|
|
11
|
+
isAbsoluteFailNode,
|
|
12
|
+
isParallelNode,
|
|
13
|
+
isWorkflowInvocationNode,
|
|
7
14
|
jsonSchema,
|
|
8
15
|
list,
|
|
9
16
|
loadFragments,
|
|
17
|
+
notify,
|
|
18
|
+
parallel,
|
|
10
19
|
promptSections,
|
|
11
20
|
promptTemplate,
|
|
12
21
|
section,
|
|
13
22
|
shape,
|
|
14
23
|
state,
|
|
15
|
-
step
|
|
24
|
+
step,
|
|
25
|
+
subPrompt,
|
|
26
|
+
workflow
|
|
16
27
|
} from "@trailstep/core";
|
|
17
28
|
|
|
18
|
-
// src/shared/assert-builder-object.ts
|
|
19
|
-
function assertBuilderObject(value, builderName) {
|
|
20
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
21
|
-
throw new TypeError(`${builderName} requires a single object argument.`);
|
|
22
|
-
}
|
|
23
|
-
if (typeof value.id !== "string") {
|
|
24
|
-
throw new TypeError(`${builderName} requires an id string.`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
29
|
// src/workflow-builder/workflow-builder.ts
|
|
29
|
-
|
|
30
|
-
assertBuilderObject(options, "defineWorkflow");
|
|
31
|
-
if (typeof options.start !== "function")
|
|
32
|
-
throw new TypeError("defineWorkflow requires a start function.");
|
|
33
|
-
return options;
|
|
34
|
-
}
|
|
30
|
+
import { defineWorkflow } from "@trailstep/core";
|
|
35
31
|
export {
|
|
36
32
|
Document,
|
|
33
|
+
absoluteDone,
|
|
34
|
+
absoluteFail,
|
|
37
35
|
defineWorkflow,
|
|
38
36
|
document,
|
|
39
37
|
done,
|
|
40
38
|
fail,
|
|
39
|
+
globalState,
|
|
40
|
+
isAbsoluteDoneNode,
|
|
41
|
+
isAbsoluteFailNode,
|
|
42
|
+
isParallelNode,
|
|
43
|
+
isWorkflowInvocationNode,
|
|
41
44
|
jsonSchema,
|
|
42
45
|
list,
|
|
43
46
|
loadFragments,
|
|
47
|
+
notify,
|
|
48
|
+
parallel,
|
|
44
49
|
promptSections,
|
|
45
50
|
promptTemplate,
|
|
46
51
|
section,
|
|
47
52
|
shape,
|
|
48
53
|
state,
|
|
49
|
-
step
|
|
54
|
+
step,
|
|
55
|
+
subPrompt,
|
|
56
|
+
workflow
|
|
50
57
|
};
|
|
51
58
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/workflow-builder/workflow-builder.ts"],"sourcesContent":["export type {\n AbsoluteDoneNode,\n AbsoluteFailNode,\n CheckWaitCallback,\n CheckWaitContext,\n CheckWaitHelpers,\n ContinuationArray,\n ContinuationResult,\n DeepReadonly,\n DisplayPhase,\n DoPhase,\n FailNode,\n NotifyApi,\n NotifyArtifact,\n ParallelNode,\n PostContinuation,\n PromptOptions,\n PromptPhase,\n PromptTemplateSource,\n RetryPolicy,\n RetryPolicyInput,\n RunnableContinuationNode,\n Schema,\n ShapeInput,\n ShapeObject,\n ShapePrimitive,\n StepConfig,\n StepContextContinuation,\n StepContinuationOutput,\n StepCwdCallback,\n StepCwdContext,\n StepCwdInput,\n StepDisplayCallback,\n StepDisplayContent,\n StepDisplayContext,\n StepDisplayLevel,\n StepDisplayObject,\n StepDisplayValue,\n StepFactory,\n StepPhase,\n StepWaitContext,\n SubPromptFactory,\n SubPromptOptions,\n TerminalMessageOptions,\n TimeoutPolicy,\n TimeoutPolicyInput,\n WaitCallback,\n WaitCheckResult,\n WaitDefinition,\n WaitDoneResult,\n WaitInput,\n WaitOptions,\n WaitPendingInput,\n WaitPendingResult,\n WaitPhase,\n Workflow,\n WorkflowInputApi,\n WorkflowInvocationNode,\n WorkflowInvocationOptions,\n WorkflowSkillOptions,\n} from \"@trailstep/core\";\nexport {\n absoluteDone,\n absoluteFail,\n Document,\n document,\n done,\n fail,\n globalState,\n isAbsoluteDoneNode,\n isAbsoluteFailNode,\n isParallelNode,\n isWorkflowInvocationNode,\n jsonSchema,\n list,\n loadFragments,\n notify,\n parallel,\n promptSections,\n promptTemplate,\n section,\n shape,\n state,\n step,\n subPrompt,\n workflow,\n} from \"@trailstep/core\";\nexport { defineWorkflow } from \"./workflow-builder/workflow-builder.js\";\nexport type {\n DefinedWorkflow,\n WorkflowBuilderOptions,\n} from \"./workflow-builder/workflow-builder.types.js\";\n","export { defineWorkflow } from \"@trailstep/core\";\n"],"mappings":";AA6DA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACtFP,SAAS,sBAAsB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trailstep/authoring",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript authoring helpers for TrailStep workflows.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"LICENSE"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@trailstep/core": "0.
|
|
32
|
+
"@trailstep/core": "0.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@trailstep/core": "^0.
|
|
35
|
+
"@trailstep/core": "^0.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@biomejs/biome": "^2.
|
|
39
|
-
"@types/node": "^26.
|
|
38
|
+
"@biomejs/biome": "^2.5.8",
|
|
39
|
+
"@types/node": "^26.2.0",
|
|
40
40
|
"tsup": "^8.5.0",
|
|
41
41
|
"typescript": "^5.8.3",
|
|
42
42
|
"vitest": "^3.2.4"
|