@ziggs-ai/agent-sdk 0.39.0 → 0.40.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.
package/CHANGELOG.md CHANGED
@@ -30,7 +30,13 @@
30
30
 
31
31
  - Notes kept with an operator key are agent-private artifacts, so they survive a restart and are not announced.
32
32
 
33
- ## Unreleased: agent vocabulary and lifecycle (breaking)
33
+ ## Unreleased
34
+
35
+ ## 0.40.1
36
+
37
+ - `createSkillAgent` offers `artifact_record`, `artifact_list`, `artifact_find`, `artifact_share` and `artifact_attach`, so an agent built from instructions can keep its work as artifacts. The file tools that return a storage URL to upload to or fetch from are not offered: the agent has no web tool, and `artifact_record` already takes a file in one call. The set stays fixed in code; instruction text cannot add tools.
38
+
39
+ ## 0.40.0
34
40
 
35
41
  - `Agent` names the body returned by `createAgent`; decision engines are `ZiggsBrain` and `ClaudeBrain`. See the README migration table.
36
42
  - Platform integration moves to `src/platform`, brains to `src/brain`, and external MCP tool composition to `src/mcp`.
package/dist/Agent.d.ts CHANGED
@@ -76,6 +76,8 @@ export interface AgentOptions {
76
76
  description?: string;
77
77
  /** Claude-brain system prompt; falls back to `description`. */
78
78
  systemPrompt?: string;
79
+ /** Read trusted role instructions afresh for each wake. Failure stops the wake. */
80
+ loadSystemPrompt?: () => Promise<string>;
79
81
  specialization?: string | null;
80
82
  /**
81
83
  * strings compared exactly against a request's `match` field.
package/dist/Agent.js CHANGED
@@ -239,6 +239,7 @@ export class Agent {
239
239
  name: resolved.name || null,
240
240
  description: resolved.description || 'A helpful assistant',
241
241
  systemPrompt: resolved.systemPrompt,
242
+ loadSystemPrompt: resolved.loadSystemPrompt,
242
243
  specialization: resolved.specialization ?? null,
243
244
  requestMatchTags: resolved.requestMatchTags,
244
245
  tools: resolved.tools || [],
@@ -418,6 +419,7 @@ export class Agent {
418
419
  toolManager: services.toolManager,
419
420
  description: this.options.description,
420
421
  systemPrompt: this.options.systemPrompt,
422
+ loadSystemPrompt: this.options.loadSystemPrompt,
421
423
  specialization: this.options.specialization,
422
424
  model: resolveClaudeModel(this.options.model, this.options.services?.llm?.model),
423
425
  anthropicKey: this.options.anthropicKey,
@@ -32,6 +32,8 @@ export interface ClaudeBrainOptions {
32
32
  description: string;
33
33
  /** The agent's system prompt. Preferred over `description` for the role block. */
34
34
  systemPrompt?: string;
35
+ /** Failure is fatal for this wake: never run with stale or fallback instructions. */
36
+ loadSystemPrompt?: () => Promise<string>;
35
37
  specialization?: string | null;
36
38
  model: string;
37
39
  anthropicKey: string;
@@ -95,6 +97,7 @@ export declare class ClaudeBrain implements Brain {
95
97
  workflow: Workflow;
96
98
  toolManager: ToolManager;
97
99
  private rolePrompt;
100
+ private loadSystemPrompt?;
98
101
  private specialization;
99
102
  private model;
100
103
  private anthropicKey;
@@ -199,6 +199,7 @@ export class ClaudeBrain {
199
199
  workflow;
200
200
  toolManager;
201
201
  rolePrompt;
202
+ loadSystemPrompt;
202
203
  specialization;
203
204
  model;
204
205
  anthropicKey;
@@ -232,13 +233,14 @@ export class ClaudeBrain {
232
233
  // written before the split still carry the prompt in `description`, so fall
233
234
  // back to it rather than silently dropping their role.
234
235
  this.rolePrompt = opts.systemPrompt || opts.description;
236
+ this.loadSystemPrompt = opts.loadSystemPrompt;
235
237
  this.specialization = opts.specialization ?? null;
236
238
  this.model = opts.model;
237
239
  this.anthropicKey = opts.anthropicKey;
238
240
  this.operatorKey = opts.operatorKey;
239
241
  this.agentId = opts.agentId;
240
242
  this.maxTurns = opts.maxTurns ?? DEFAULT_MAX_TURNS;
241
- this.statelessPerWake = opts.statelessPerWake ?? false;
243
+ this.statelessPerWake = opts.statelessPerWake ?? !!opts.loadSystemPrompt;
242
244
  this.queryFn = opts.queryFn ?? query;
243
245
  this.readAgreement = opts.readAgreement ?? ((agreementId) => getAgreement(agreementId, {
244
246
  operatorKey: this.operatorKey,
@@ -393,9 +395,16 @@ export class ClaudeBrain {
393
395
  };
394
396
  }
395
397
  }
398
+ // Keep it local: different conversation lanes can wake concurrently.
399
+ // An unavailable/revoked instruction source must not fall back to yesterday's role.
400
+ const rolePrompt = this.loadSystemPrompt
401
+ ? await this.loadSystemPrompt()
402
+ : this.rolePrompt;
403
+ if (!rolePrompt.trim())
404
+ throw new Error('Agent instructions are empty');
396
405
  const roleBlock = [
397
406
  `## Your role`,
398
- this.rolePrompt,
407
+ rolePrompt,
399
408
  this.specialization ? `Specialization: ${this.specialization}` : '',
400
409
  ].filter(Boolean).join('\n');
401
410
  // Two blocks, not one string: the shared protocol first so its cache prefix
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export type { ParsedSkill, SkillFile, SkillReference } from './skills/parseSkill
15
15
  export { loadSkill, readSkillFiles, assertSkillHash } from './skills/loadSkill.js';
16
16
  export { skillReadReferenceTool } from './skills/skillReadReference.js';
17
17
  export { Agent, createAgent, createAgentPool, DEFAULT_MODEL, resolveFleetModel } from './Agent.js';
18
+ export { createSkillAgent } from './skills/createSkillAgent.js';
18
19
  export { ZiggsBrain } from './brain/ZiggsBrain.js';
19
20
  export { ClaudeBrain } from './brain/ClaudeBrain.js';
20
21
  export type { CognitionKind, ClaudeBrainOptions } from './brain/ClaudeBrain.js';
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export { parseSkill, skillHash, skillRolePrompt, skillReferenceName, skillRefere
17
17
  export { loadSkill, readSkillFiles, assertSkillHash } from './skills/loadSkill.js';
18
18
  export { skillReadReferenceTool } from './skills/skillReadReference.js';
19
19
  export { Agent, createAgent, createAgentPool, DEFAULT_MODEL, resolveFleetModel } from './Agent.js';
20
+ export { createSkillAgent } from './skills/createSkillAgent.js';
20
21
  export { ZiggsBrain } from './brain/ZiggsBrain.js';
21
22
  export { ClaudeBrain } from './brain/ClaudeBrain.js';
22
23
  // The exact strings a Claude-brain wake sends: the shared protocol block, the
@@ -0,0 +1,12 @@
1
+ import { type AgentOptions } from '../Agent.js';
2
+ /** The same instructions run on a host or on a person's machine. The trusted
3
+ * caller supplies bytes; instruction text cannot add tools or runtime options.
4
+ */
5
+ export declare function createSkillAgent(options: {
6
+ agentId: string;
7
+ operatorKey: string;
8
+ readInstructions: () => Promise<string>;
9
+ model?: string;
10
+ anthropicKey?: string;
11
+ metricsTap?: AgentOptions['metricsTap'];
12
+ }): import("../Agent.js").Agent;
@@ -0,0 +1,41 @@
1
+ import { createAgent } from '../Agent.js';
2
+ import { ARTIFACT_TOOLS } from '../platform/tools/tier2/artifactTools.js';
3
+ import { toolName } from '../tools/defineTool.js';
4
+ import { parseSkill, skillRolePrompt } from './parseSkill.js';
5
+ /** The artifact tools that finish inside one call, so instructions can keep
6
+ * their work as artifacts. The rest hand back a storage URL to upload to or
7
+ * fetch from, and this agent has no web tool to do that with.
8
+ */
9
+ const SKILL_ARTIFACT_TOOL_NAMES = new Set([
10
+ 'artifact_record',
11
+ 'artifact_list',
12
+ 'artifact_find',
13
+ 'artifact_share',
14
+ 'artifact_attach',
15
+ ]);
16
+ const SKILL_ARTIFACT_TOOLS = ARTIFACT_TOOLS.filter((tool) => SKILL_ARTIFACT_TOOL_NAMES.has(toolName(tool) ?? ''));
17
+ /** The same instructions run on a host or on a person's machine. The trusted
18
+ * caller supplies bytes; instruction text cannot add tools or runtime options.
19
+ */
20
+ export function createSkillAgent(options) {
21
+ return createAgent({
22
+ agentId: options.agentId,
23
+ operatorKey: options.operatorKey,
24
+ anthropicKey: options.anthropicKey,
25
+ model: options.model,
26
+ cognition: 'claude-sdk',
27
+ description: 'An agent running instructions shared by its owner.',
28
+ loadSystemPrompt: async () => {
29
+ const text = await options.readInstructions();
30
+ const skill = parseSkill([{ path: 'SKILL.md', bytes: Buffer.from(text, 'utf8') }]);
31
+ return skillRolePrompt(skill);
32
+ },
33
+ tools: [...SKILL_ARTIFACT_TOOLS],
34
+ taskTools: 'all',
35
+ actsOnHireActivation: true,
36
+ respondsToProposals: true,
37
+ metricsTap: options.metricsTap,
38
+ initial: 'ready',
39
+ states: { ready: { kind: 'parked', transitions: [] } },
40
+ });
41
+ }
package/dist/types.d.ts CHANGED
@@ -590,6 +590,8 @@ export interface DefineAgentInput {
590
590
  * relies on. Never surfaced in the store.
591
591
  */
592
592
  systemPrompt?: string;
593
+ /** Trusted host callback, read at every wake; never exposed to the model. */
594
+ loadSystemPrompt?: () => Promise<string>;
593
595
  specialization?: string;
594
596
  initial: string;
595
597
  states: Record<string, State>;
@@ -622,6 +624,7 @@ export interface AgentConfig {
622
624
  description: string;
623
625
  /** Claude-brain system prompt; falls back to `description`. */
624
626
  systemPrompt?: string;
627
+ loadSystemPrompt?: () => Promise<string>;
625
628
  specialization?: string;
626
629
  tools: unknown[];
627
630
  /** Normalized declared needs — see DefineAgentInput.needs. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/agent-sdk",
3
- "version": "0.39.0",
3
+ "version": "0.40.1",
4
4
  "description": "Agent framework SDK for building autonomous agents on the Ziggs platform",
5
5
  "homepage": "https://ziggsai.com/docs",
6
6
  "bugs": {
@@ -30,7 +30,7 @@
30
30
  "@anthropic-ai/claude-agent-sdk": "^0.3.284",
31
31
  "@anthropic-ai/sdk": "^0.110.0",
32
32
  "@modelcontextprotocol/sdk": "^1.29.0",
33
- "@ziggs-ai/api-client": "0.37.21",
33
+ "@ziggs-ai/api-client": "0.37.23",
34
34
  "@ziggs-ai/contracts": "^0.23.3",
35
35
  "ajv": "^8.17.1",
36
36
  "dotenv": "^17.2.3",