@vimhead.dev/norn 0.1.0-tip.35436871363.1 → 0.1.0-tip.35568631545.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/api.d.ts +25 -22
  2. package/dist/api.js +14 -14
  3. package/package.json +1 -1
package/dist/api.d.ts CHANGED
@@ -55,6 +55,9 @@ export type NornWorkflowContext<ArgsSchema extends TSchema = TSchema, ConfigSche
55
55
  readonly args: StaticDecode<ArgsSchema>;
56
56
  readonly config: WorkflowConfig<ConfigSchema>;
57
57
  readonly paths: NornWorkflowPaths;
58
+ readonly agents: NornAgents;
59
+ readonly commands: NornCommands;
60
+ readonly logs: NornLogs;
58
61
  readonly run: NornRun;
59
62
  } & (Scope extends NornWorkflowScopeInfo ? {
60
63
  readonly scope: {
@@ -62,8 +65,8 @@ export type NornWorkflowContext<ArgsSchema extends TSchema = TSchema, ConfigSche
62
65
  readonly config: WorkflowConfig<Scope["config"]>;
63
66
  };
64
67
  } : {});
65
- export type NornWorkflowDefinition<Id extends string = string, ArgsSchema extends TSchema = TSchema, ConfigSchema extends TSchema | undefined = undefined, Scope extends NornWorkflowScopeInfo | undefined = undefined> = {
66
- readonly id: Id;
68
+ export type NornWorkflowDefinition<Name extends string = string, ArgsSchema extends TSchema = TSchema, ConfigSchema extends TSchema | undefined = undefined, Scope extends NornWorkflowScopeInfo | undefined = undefined> = {
69
+ readonly name: Name;
67
70
  readonly args: ArgsSchema;
68
71
  readonly config?: ConfigSchema;
69
72
  readonly gate?: NornWorkflowGate<ArgsSchema> & {
@@ -75,22 +78,22 @@ export type NornWorkflowScopeInfo = {
75
78
  readonly id: string;
76
79
  readonly config?: TSchema;
77
80
  };
78
- export type NornWorkflowScope<Id extends string, ConfigSchema extends TSchema | undefined> = {
79
- readonly id: Id;
81
+ export type NornWorkflowScope<Name extends string, ConfigSchema extends TSchema | undefined> = {
82
+ readonly id: Name;
80
83
  readonly config: ConfigSchema;
81
- workflow<const LocalId extends string, ArgsSchema extends TSchema, LocalConfig extends TSchema | undefined = undefined>(definition: NornWorkflowDefinition<LocalId, ArgsSchema, LocalConfig, {
82
- readonly id: Id;
84
+ workflow<const LocalName extends string, ArgsSchema extends TSchema, LocalConfig extends TSchema | undefined = undefined>(definition: NornWorkflowDefinition<LocalName, ArgsSchema, LocalConfig, {
85
+ readonly id: Name;
83
86
  readonly config: ConfigSchema;
84
- }>): NornWorkflowDeclaration<`${Id}.${LocalId}`, ArgsSchema, LocalConfig, {
85
- readonly id: Id;
87
+ }>): NornWorkflowDeclaration<`${Name}.${LocalName}`, ArgsSchema, LocalConfig, {
88
+ readonly id: Name;
86
89
  readonly config: ConfigSchema;
87
90
  }>;
88
91
  };
89
- export declare function workflow<const Id extends string, ArgsSchema extends TSchema, ConfigSchema extends TSchema | undefined = undefined>(definition: NornWorkflowDefinition<Id, ArgsSchema, ConfigSchema>): NornWorkflowDeclaration<Id, ArgsSchema, ConfigSchema, undefined>;
90
- export declare function workflowScope<const Id extends string, ConfigSchema extends TSchema | undefined = undefined>(input: {
91
- readonly id: Id;
92
+ export declare function workflow<const Name extends string, ArgsSchema extends TSchema, ConfigSchema extends TSchema | undefined = undefined>(definition: NornWorkflowDefinition<Name, ArgsSchema, ConfigSchema>): NornWorkflowDeclaration<Name, ArgsSchema, ConfigSchema, undefined>;
93
+ export declare function workflowScope<const Name extends string, ConfigSchema extends TSchema | undefined = undefined>(input: {
94
+ readonly name: Name;
92
95
  readonly config?: ConfigSchema;
93
- }): NornWorkflowScope<Id, ConfigSchema>;
96
+ }): NornWorkflowScope<Name, ConfigSchema>;
94
97
  export type NornRunNext = {
95
98
  readonly type: "next";
96
99
  readonly workflowId: string;
@@ -364,16 +367,16 @@ export type NornRun = {
364
367
  fail(metadata: NornRunOutcomeMetadata & {
365
368
  readonly summary: string;
366
369
  }): NornRunFail;
367
- logs: {
368
- read(log: NornLogRef): Promise<string>;
369
- };
370
- commands: {
371
- run(input: NornCommandRunInput): Promise<NornCommandRunResult>;
372
- };
373
- agents: {
374
- createSession(input: NornAgentCreateSessionInput): Promise<NornAgentSession>;
375
- prompt<ResponseSchema extends TSchema>(input: NornAgentSinglePromptInput<ResponseSchema>): Promise<StaticDecode<ResponseSchema>>;
376
- };
370
+ };
371
+ export type NornLogs = {
372
+ read(log: NornLogRef): Promise<string>;
373
+ };
374
+ export type NornCommands = {
375
+ run(input: NornCommandRunInput): Promise<NornCommandRunResult>;
376
+ };
377
+ export type NornAgents = {
378
+ createSession(input: NornAgentCreateSessionInput): Promise<NornAgentSession>;
379
+ prompt<ResponseSchema extends TSchema>(input: NornAgentSinglePromptInput<ResponseSchema>): Promise<StaticDecode<ResponseSchema>>;
377
380
  };
378
381
  export type NornWorkflowSource = {
379
382
  readonly path: string;
package/dist/api.js CHANGED
@@ -12,29 +12,29 @@ import { Value } from "typebox/value";
12
12
  import { assertWorkflowMetadata, isPlainObject, jsonValueSchema } from "./schema.js";
13
13
  var WORKFLOW_DECLARATION_KIND = "norn.workflow";
14
14
  function workflow(definition) {
15
- return createWorkflow({ definition, scope: void 0 });
15
+ return createWorkflow({ definition, id: definition.name, scope: void 0 });
16
16
  }
17
17
  function createWorkflow(input) {
18
- const { definition, scope } = input;
19
- assertDeclarationId(definition.id);
20
- const callable = (args) => createWorkflowTransition({ workflowId: definition.id, args });
21
- const result = Object.assign(callable, definition, {
18
+ const { definition: { name, ...properties }, id, scope } = input;
19
+ assertDeclarationName(name);
20
+ const callable = (args) => createWorkflowTransition({ workflowId: id, args });
21
+ const result = Object.assign(callable, properties, {
22
22
  kind: WORKFLOW_DECLARATION_KIND,
23
+ id,
23
24
  scope
24
25
  });
25
- if (!isWorkflowDeclaration(result)) throw new Error(`Invalid workflow definition: ${definition.id}`);
26
+ if (!isWorkflowDeclaration(result)) throw new Error(`Invalid workflow definition: ${id}`);
26
27
  assertWorkflowMetadata(result);
27
28
  return result;
28
29
  }
29
30
  function workflowScope(input) {
30
- assertDeclarationId(input.id);
31
- const scope = { id: input.id, config: input.config };
31
+ assertDeclarationName(input.name);
32
+ const scope = { id: input.name, config: input.config };
32
33
  return {
33
- id: input.id,
34
- config: input.config,
34
+ id: scope.id,
35
+ config: scope.config,
35
36
  workflow(definition) {
36
- assertDeclarationId(definition.id);
37
- return createWorkflow({ definition: { ...definition, id: `${input.id}.${definition.id}` }, scope });
37
+ return createWorkflow({ definition, id: `${scope.id}.${definition.name}`, scope });
38
38
  }
39
39
  };
40
40
  }
@@ -56,8 +56,8 @@ function workflowRefSchema(options) {
56
56
  };
57
57
  }), { "x-norn-workflow-ref": { contributedArgsSchema: contributionSchema } });
58
58
  }
59
- function assertDeclarationId(id) {
60
- if (typeof id !== "string" || id.trim().length === 0 || id.split(".").some((segment) => segment.length === 0)) throw new Error(`Invalid workflow or scope id: ${id}`);
59
+ function assertDeclarationName(name) {
60
+ if (typeof name !== "string" || name.trim().length === 0 || name.includes(".")) throw new Error(`Invalid workflow or scope name: ${name}; expected a nonempty name without dots`);
61
61
  }
62
62
  function isWorkflowDeclaration(value) {
63
63
  if (typeof value !== "function") return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vimhead.dev/norn",
3
- "version": "0.1.0-tip.35436871363.1",
3
+ "version": "0.1.0-tip.35568631545.1",
4
4
  "description": "TypeScript SDK for building agent-driven and code-driven Norn workflows.",
5
5
  "type": "module",
6
6
  "license": "MIT",