@agentic-surfaces/core 0.1.25 → 0.1.27
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/agents.d.ts +3 -0
- package/dist/agents.js +9 -0
- package/dist/handlers/agent.js +15 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pause.d.ts +21 -0
- package/dist/pause.js +26 -0
- package/dist/project-config.d.ts +11 -0
- package/dist/project-config.js +9 -0
- package/dist/scheduler.d.ts +6 -1
- package/dist/scheduler.js +20 -9
- package/dist/types.d.ts +6 -2
- package/package.json +2 -2
package/dist/agents.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Capabilities } from "@agentic-surfaces/agent";
|
|
1
2
|
export interface AgentCommand {
|
|
2
3
|
name: string;
|
|
3
4
|
description?: string;
|
|
@@ -16,6 +17,8 @@ export interface AgentDefinition {
|
|
|
16
17
|
command?: string;
|
|
17
18
|
args?: string[];
|
|
18
19
|
}>;
|
|
20
|
+
/** Declared plugins/skills/settingSources for a `full` agent (config, not env-assumed). */
|
|
21
|
+
capabilities?: Capabilities;
|
|
19
22
|
instructions: string;
|
|
20
23
|
}
|
|
21
24
|
/**
|
package/dist/agents.js
CHANGED
|
@@ -11,6 +11,13 @@ const AgentCommandSchema = z.object({
|
|
|
11
11
|
name: z.string().min(1),
|
|
12
12
|
description: z.string().optional(),
|
|
13
13
|
});
|
|
14
|
+
// Declared capabilities for a capable (`full`) agent — plugins/skills/settingSources the engine
|
|
15
|
+
// loads explicitly (config, not an assumption about the operator's `~/.claude`).
|
|
16
|
+
const CapabilitiesSchema = z.object({
|
|
17
|
+
plugins: z.array(z.object({ path: z.string().min(1) })).optional(),
|
|
18
|
+
skills: z.union([z.literal("all"), z.array(z.string())]).optional(),
|
|
19
|
+
settingSources: z.array(z.enum(["user", "project", "local"])).optional(),
|
|
20
|
+
});
|
|
14
21
|
const AgentFrontmatterSchema = z
|
|
15
22
|
.object({
|
|
16
23
|
name: z.string().min(1).optional(),
|
|
@@ -20,6 +27,7 @@ const AgentFrontmatterSchema = z
|
|
|
20
27
|
commands: z.array(AgentCommandSchema).min(1).optional(),
|
|
21
28
|
fallback: z.string().optional(),
|
|
22
29
|
mcpServers: z.array(McpServerRefSchema).optional(),
|
|
30
|
+
capabilities: CapabilitiesSchema.optional(),
|
|
23
31
|
})
|
|
24
32
|
.superRefine((v, ctx) => {
|
|
25
33
|
if (v.commands) {
|
|
@@ -70,6 +78,7 @@ export function parseAgentFile(content, defaultName) {
|
|
|
70
78
|
commands: fm.commands,
|
|
71
79
|
fallback: fm.fallback,
|
|
72
80
|
mcpServers: fm.mcpServers,
|
|
81
|
+
capabilities: fm.capabilities,
|
|
73
82
|
instructions: body.trim(),
|
|
74
83
|
};
|
|
75
84
|
}
|
package/dist/handlers/agent.js
CHANGED
|
@@ -39,6 +39,16 @@ export const agentHandler = {
|
|
|
39
39
|
model = model ?? defaults.model;
|
|
40
40
|
effort = effort ?? defaults.effort;
|
|
41
41
|
mcpServers = mcpServers ?? defaults.mcpServers;
|
|
42
|
+
// Capabilities: per-agent frontmatter overrides project defaults field-by-field.
|
|
43
|
+
const agentCaps = (cfg.agent ? ctx.services.agents?.get(cfg.agent)?.capabilities : undefined);
|
|
44
|
+
const defCaps = defaults.capabilities;
|
|
45
|
+
const capabilities = (agentCaps || defCaps)
|
|
46
|
+
? {
|
|
47
|
+
plugins: agentCaps?.plugins ?? defCaps?.plugins,
|
|
48
|
+
skills: agentCaps?.skills ?? defCaps?.skills,
|
|
49
|
+
settingSources: agentCaps?.settingSources ?? defCaps?.settingSources,
|
|
50
|
+
}
|
|
51
|
+
: undefined;
|
|
42
52
|
const result = await ctx.services.agent.run({
|
|
43
53
|
prompt: instructions,
|
|
44
54
|
model,
|
|
@@ -49,6 +59,9 @@ export const agentHandler = {
|
|
|
49
59
|
// Capability tier (default constrained) + dry-run so the runner's permission callback can
|
|
50
60
|
// block + log writes for surface/full agents. Logged via the engine logger for visibility.
|
|
51
61
|
profile: profile ?? "constrained",
|
|
62
|
+
capabilities,
|
|
63
|
+
// A `full` agent's working dir + base for resolving relative plugin paths = the project dir.
|
|
64
|
+
cwd: ctx.services.projectDir,
|
|
52
65
|
dryRun: ctx.services.dryRun,
|
|
53
66
|
log: (m) => ctx.services.logger?.info?.(m),
|
|
54
67
|
// Stream the agent's reasoning + tool/MCP calls to the run observer, tagged with this node.
|
|
@@ -66,11 +79,11 @@ export const agentHandler = {
|
|
|
66
79
|
else
|
|
67
80
|
throw new Error(`agent ${cfg.agent} returned an off-allowlist command: ${String(raw)}`);
|
|
68
81
|
}
|
|
69
|
-
return { output: { command, text: result.text } };
|
|
82
|
+
return { output: { command, text: result.text, skillsUsed: result.skillsUsed, toolsUsed: result.toolsUsed, usage: result.usage } };
|
|
70
83
|
}
|
|
71
84
|
// Inline decision schema: surface its fields at the top level (0.1.7 behaviour).
|
|
72
85
|
if (cfg.decision && result.data && typeof result.data === "object" && !Array.isArray(result.data)) {
|
|
73
|
-
return { output: { ...result.data, text: result.text } };
|
|
86
|
+
return { output: { ...result.data, text: result.text, skillsUsed: result.skillsUsed, toolsUsed: result.toolsUsed, usage: result.usage } };
|
|
74
87
|
}
|
|
75
88
|
return { output: result };
|
|
76
89
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./cache.js";
|
|
|
7
7
|
export * from "./observer.js";
|
|
8
8
|
export * from "./secrets.js";
|
|
9
9
|
export * from "./project-config.js";
|
|
10
|
+
export * from "./pause.js";
|
|
10
11
|
export * from "./agents.js";
|
|
11
12
|
export * from "./handlers/foreach.js";
|
|
12
13
|
export * from "./handlers/run-workflow.js";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./cache.js";
|
|
|
7
7
|
export * from "./observer.js";
|
|
8
8
|
export * from "./secrets.js";
|
|
9
9
|
export * from "./project-config.js";
|
|
10
|
+
export * from "./pause.js";
|
|
10
11
|
export * from "./agents.js";
|
|
11
12
|
export * from "./handlers/foreach.js";
|
|
12
13
|
export * from "./handlers/run-workflow.js";
|
package/dist/pause.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A platform-wide play/pause switch. When paused, the scheduler stops firing cron workflows
|
|
3
|
+
* (in-flight runs finish; new scheduled fires are skipped). It's a master switch for the
|
|
4
|
+
* autonomous loop — manual dashboard runs still work.
|
|
5
|
+
*/
|
|
6
|
+
export interface PauseState {
|
|
7
|
+
isPaused(): boolean;
|
|
8
|
+
pause(): void;
|
|
9
|
+
resume(): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* File-backed pause state: the presence of a sentinel file (default `.flow-paused`) means paused.
|
|
13
|
+
* A file (not in-memory) so the state survives a `start --watch` restart and is inspectable.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FilePauseState implements PauseState {
|
|
16
|
+
private readonly path;
|
|
17
|
+
constructor(path?: string);
|
|
18
|
+
isPaused(): boolean;
|
|
19
|
+
pause(): void;
|
|
20
|
+
resume(): void;
|
|
21
|
+
}
|
package/dist/pause.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { existsSync, writeFileSync, rmSync } from "node:fs";
|
|
2
|
+
/**
|
|
3
|
+
* File-backed pause state: the presence of a sentinel file (default `.flow-paused`) means paused.
|
|
4
|
+
* A file (not in-memory) so the state survives a `start --watch` restart and is inspectable.
|
|
5
|
+
*/
|
|
6
|
+
export class FilePauseState {
|
|
7
|
+
path;
|
|
8
|
+
constructor(path = ".flow-paused") {
|
|
9
|
+
this.path = path;
|
|
10
|
+
}
|
|
11
|
+
isPaused() {
|
|
12
|
+
return existsSync(this.path);
|
|
13
|
+
}
|
|
14
|
+
pause() {
|
|
15
|
+
if (!this.isPaused())
|
|
16
|
+
writeFileSync(this.path, `paused ${new Date().toISOString()}\n`);
|
|
17
|
+
}
|
|
18
|
+
resume() {
|
|
19
|
+
try {
|
|
20
|
+
rmSync(this.path);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
/* already gone — nothing to do */
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dist/project-config.d.ts
CHANGED
|
@@ -19,6 +19,17 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
19
19
|
command: z.ZodString;
|
|
20
20
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
21
|
}, z.core.$strip>]>>>;
|
|
22
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
}, z.core.$strip>>>;
|
|
26
|
+
skills: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>>;
|
|
27
|
+
settingSources: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
28
|
+
user: "user";
|
|
29
|
+
project: "project";
|
|
30
|
+
local: "local";
|
|
31
|
+
}>>>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
22
33
|
}, z.core.$strip>>;
|
|
23
34
|
workflows: z.ZodOptional<z.ZodString>;
|
|
24
35
|
}, z.core.$strip>;
|
package/dist/project-config.js
CHANGED
|
@@ -16,6 +16,15 @@ const ProjectConfigSchema = z.object({
|
|
|
16
16
|
model: z.string().default("claude-opus-4-8"),
|
|
17
17
|
effort: z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
18
18
|
mcpServers: z.array(McpServerRefSchema).optional(),
|
|
19
|
+
// Project-wide default capabilities for `full` agents — declared, the engine loads them.
|
|
20
|
+
// A per-agent `capabilities` block (frontmatter) overrides this field-by-field.
|
|
21
|
+
capabilities: z
|
|
22
|
+
.object({
|
|
23
|
+
plugins: z.array(z.object({ path: z.string().min(1) })).optional(),
|
|
24
|
+
skills: z.union([z.literal("all"), z.array(z.string())]).optional(),
|
|
25
|
+
settingSources: z.array(z.enum(["user", "project", "local"])).optional(),
|
|
26
|
+
})
|
|
27
|
+
.optional(),
|
|
19
28
|
})
|
|
20
29
|
.default({ runner: "claude", model: "claude-opus-4-8" }),
|
|
21
30
|
workflows: z.string().optional(), // relative subdir; omitted = use dir itself
|
package/dist/scheduler.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HandlerRegistry } from "./registry.js";
|
|
2
|
+
import type { PauseState } from "./pause.js";
|
|
2
3
|
import type { RunObserver, Services, Workflow } from "./types.js";
|
|
3
4
|
export declare function defaultRegistry(): HandlerRegistry;
|
|
4
5
|
export declare function runWorkflowOnce(workflow: Workflow, opts: {
|
|
@@ -19,11 +20,15 @@ export declare class Scheduler {
|
|
|
19
20
|
private services;
|
|
20
21
|
private registry;
|
|
21
22
|
private observer;
|
|
23
|
+
/** When set + paused, scheduled cron fires are skipped (the platform-wide play/pause switch). */
|
|
24
|
+
private pause?;
|
|
22
25
|
private crons;
|
|
23
26
|
private active;
|
|
24
27
|
private pending;
|
|
25
28
|
private workflows;
|
|
26
|
-
constructor(services: Services, registry?: HandlerRegistry, observer?: RunObserver
|
|
29
|
+
constructor(services: Services, registry?: HandlerRegistry, observer?: RunObserver,
|
|
30
|
+
/** When set + paused, scheduled cron fires are skipped (the platform-wide play/pause switch). */
|
|
31
|
+
pause?: PauseState | undefined);
|
|
27
32
|
add(workflow: Workflow): void;
|
|
28
33
|
start(): void;
|
|
29
34
|
private enqueue;
|
package/dist/scheduler.js
CHANGED
|
@@ -58,14 +58,18 @@ export class Scheduler {
|
|
|
58
58
|
services;
|
|
59
59
|
registry;
|
|
60
60
|
observer;
|
|
61
|
+
pause;
|
|
61
62
|
crons = [];
|
|
62
63
|
active = 0;
|
|
63
64
|
pending = [];
|
|
64
65
|
workflows = [];
|
|
65
|
-
constructor(services, registry = defaultRegistry(), observer = new ConsoleObserver()
|
|
66
|
+
constructor(services, registry = defaultRegistry(), observer = new ConsoleObserver(),
|
|
67
|
+
/** When set + paused, scheduled cron fires are skipped (the platform-wide play/pause switch). */
|
|
68
|
+
pause) {
|
|
66
69
|
this.services = services;
|
|
67
70
|
this.registry = registry;
|
|
68
71
|
this.observer = observer;
|
|
72
|
+
this.pause = pause;
|
|
69
73
|
}
|
|
70
74
|
add(workflow) { this.workflows.push(workflow); }
|
|
71
75
|
start() {
|
|
@@ -74,14 +78,21 @@ export class Scheduler {
|
|
|
74
78
|
if (node.type !== "trigger.cron")
|
|
75
79
|
continue;
|
|
76
80
|
const pattern = String(node.config.cron);
|
|
77
|
-
this.crons.push(new Cron(pattern, () =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
this.crons.push(new Cron(pattern, () => {
|
|
82
|
+
// Platform-wide pause: skip this scheduled fire (in-flight runs are unaffected).
|
|
83
|
+
if (this.pause?.isPaused()) {
|
|
84
|
+
this.services.logger?.info?.(`paused — skipping scheduled run of ${wf.name}`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.enqueue(() => runWorkflowOnce(wf, { registry: this.registry, services: this.services, triggerNodeId: node.id, observer: this.observer })
|
|
88
|
+
.then(() => { })
|
|
89
|
+
// A failed scheduled run must not crash the scheduler (unhandled
|
|
90
|
+
// rejection). The failure is already reported to the observer; log
|
|
91
|
+
// and carry on so the next trigger still fires.
|
|
92
|
+
.catch((err) => this.services.logger?.error?.("scheduled run failed", {
|
|
93
|
+
workflow: wf.name, error: err instanceof Error ? err.message : String(err),
|
|
94
|
+
})));
|
|
95
|
+
}));
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
98
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AgentRunner, McpServerRef, AgentActivity } from "@agentic-surfaces/agent";
|
|
1
|
+
import type { AgentRunner, McpServerRef, AgentActivity, Capabilities } from "@agentic-surfaces/agent";
|
|
2
2
|
import type { AgentDefinition } from "./agents.js";
|
|
3
|
-
export type { AgentRunner, McpServerRef, AgentActivity };
|
|
3
|
+
export type { AgentRunner, McpServerRef, AgentActivity, Capabilities };
|
|
4
4
|
export type NodeType = "trigger.cron" | "trigger.webhook" | "trigger.command" | "task.http" | "task.transform" | "task.branch" | "task.run-workflow" | "task.foreach" | "task.cache-unseen" | "task.cache-mark" | "agent.run";
|
|
5
5
|
export interface RetryPolicy {
|
|
6
6
|
maxAttempts: number;
|
|
@@ -62,7 +62,11 @@ export interface Services {
|
|
|
62
62
|
effort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
63
63
|
runner?: string;
|
|
64
64
|
mcpServers?: McpServerRef[];
|
|
65
|
+
capabilities?: Capabilities;
|
|
65
66
|
};
|
|
67
|
+
/** The project directory (where agentic-surfaces.config.yaml lives). Base for a `full` agent's
|
|
68
|
+
* cwd and for resolving relative capability plugin paths. */
|
|
69
|
+
projectDir?: string;
|
|
66
70
|
runWorkflow?: (name: string, payload: unknown) => Promise<Map<string, unknown>>;
|
|
67
71
|
agents?: Map<string, AgentDefinition>;
|
|
68
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentic-surfaces/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"jsonata": "^2.2.1",
|
|
25
25
|
"yaml": "^2.9.0",
|
|
26
26
|
"zod": "^4.4.3",
|
|
27
|
-
"@agentic-surfaces/agent": "0.1.
|
|
27
|
+
"@agentic-surfaces/agent": "0.1.27"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/better-sqlite3": "^7.6.13",
|