@pixelml/agenticflow-cli 1.3.1 → 1.5.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.
Files changed (42) hide show
  1. package/dist/__tests__/chat-truncation.test.d.ts +2 -0
  2. package/dist/__tests__/chat-truncation.test.d.ts.map +1 -0
  3. package/dist/__tests__/chat-truncation.test.js +105 -0
  4. package/dist/__tests__/chat-truncation.test.js.map +1 -0
  5. package/dist/__tests__/run-truncation.test.d.ts +2 -0
  6. package/dist/__tests__/run-truncation.test.d.ts.map +1 -0
  7. package/dist/__tests__/run-truncation.test.js +120 -0
  8. package/dist/__tests__/run-truncation.test.js.map +1 -0
  9. package/dist/cli/blueprint-to-workforce.d.ts +51 -0
  10. package/dist/cli/blueprint-to-workforce.d.ts.map +1 -0
  11. package/dist/cli/blueprint-to-workforce.js +97 -0
  12. package/dist/cli/blueprint-to-workforce.js.map +1 -0
  13. package/dist/cli/changelog.d.ts.map +1 -1
  14. package/dist/cli/changelog.js +42 -0
  15. package/dist/cli/changelog.js.map +1 -1
  16. package/dist/cli/company-io.d.ts +157 -0
  17. package/dist/cli/company-io.d.ts.map +1 -0
  18. package/dist/cli/company-io.js +373 -0
  19. package/dist/cli/company-io.js.map +1 -0
  20. package/dist/cli/main.d.ts.map +1 -1
  21. package/dist/cli/main.js +816 -11
  22. package/dist/cli/main.js.map +1 -1
  23. package/dist/cli/platform-catalog.d.ts +67 -0
  24. package/dist/cli/platform-catalog.d.ts.map +1 -0
  25. package/dist/cli/platform-catalog.js +200 -0
  26. package/dist/cli/platform-catalog.js.map +1 -0
  27. package/dist/cli/playbooks.d.ts.map +1 -1
  28. package/dist/cli/playbooks.js +166 -0
  29. package/dist/cli/playbooks.js.map +1 -1
  30. package/dist/cli/utils/deprecation.d.ts +24 -0
  31. package/dist/cli/utils/deprecation.d.ts.map +1 -0
  32. package/dist/cli/utils/deprecation.js +33 -0
  33. package/dist/cli/utils/deprecation.js.map +1 -0
  34. package/dist/cli/utils/mcp-inspect.d.ts +28 -0
  35. package/dist/cli/utils/mcp-inspect.d.ts.map +1 -0
  36. package/dist/cli/utils/mcp-inspect.js +90 -0
  37. package/dist/cli/utils/mcp-inspect.js.map +1 -0
  38. package/dist/cli/utils/patch.d.ts +47 -0
  39. package/dist/cli/utils/patch.d.ts.map +1 -0
  40. package/dist/cli/utils/patch.js +87 -0
  41. package/dist/cli/utils/patch.js.map +1 -0
  42. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chat-truncation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-truncation.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/chat-truncation.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,105 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { runCli } from "../cli/main.js";
3
+ // Mock createClient so buildClient() gets our fake client
4
+ vi.mock("@pixelml/agenticflow-sdk", async (importOriginal) => {
5
+ const actual = await importOriginal();
6
+ return { ...actual, createClient: vi.fn() };
7
+ });
8
+ // Mock readline so we can drive the chat loop from tests
9
+ vi.mock("node:readline", () => ({
10
+ createInterface: vi.fn(),
11
+ }));
12
+ import { createClient } from "@pixelml/agenticflow-sdk";
13
+ import { createInterface } from "node:readline";
14
+ const mockCreateClient = createClient;
15
+ const mockCreateInterface = createInterface;
16
+ /** Build a fake readline that answers one question then throws to exit the loop */
17
+ function makeReadline(answer) {
18
+ let callNum = 0;
19
+ const rl = {
20
+ question: vi.fn((_prompt, cb) => {
21
+ callNum++;
22
+ if (callNum === 1) {
23
+ cb(answer);
24
+ }
25
+ else {
26
+ throw new Error("TEST_EOF");
27
+ }
28
+ }),
29
+ close: vi.fn(),
30
+ on: vi.fn(),
31
+ };
32
+ return rl;
33
+ }
34
+ /** Build a fake AgentStream */
35
+ function makeStream(parts, threadId = "tid-chat-1") {
36
+ return {
37
+ on: vi.fn(),
38
+ process: vi.fn().mockResolvedValue(undefined),
39
+ parts: vi.fn().mockResolvedValue(parts),
40
+ threadId,
41
+ };
42
+ }
43
+ describe("af agent chat truncation (CHAT-01)", () => {
44
+ let originalArgv;
45
+ let stderrSpy;
46
+ beforeEach(() => {
47
+ originalArgv = [...process.argv];
48
+ stderrSpy = vi.spyOn(process.stderr, "write").mockImplementation(() => true);
49
+ vi.spyOn(process.stdout, "write").mockImplementation(() => true);
50
+ vi.spyOn(console, "error").mockImplementation(() => { });
51
+ vi.spyOn(process, "exit").mockImplementation((code) => {
52
+ throw Object.assign(new Error(`EXIT:${code ?? 0}`), { exitCode: code });
53
+ });
54
+ });
55
+ afterEach(() => {
56
+ process.argv = originalArgv;
57
+ vi.restoreAllMocks();
58
+ });
59
+ // TODO(v1.5-debt): `af agent chat` subcommand not yet implemented; see main.test.ts `agent chat` todo.
60
+ it.skip("writes truncation warning to stderr when reply is cut short", async () => {
61
+ mockCreateInterface.mockReturnValue(makeReadline("hi"));
62
+ const fakeStream = makeStream([{ type: "finish", value: { finishReason: "length" } }]);
63
+ mockCreateClient.mockReturnValue({
64
+ sdk: { workspaceId: "ws-test" },
65
+ agents: { stream: vi.fn().mockResolvedValue(fakeStream) },
66
+ });
67
+ const agentId = "00000000-0000-0000-0000-000000000001";
68
+ process.argv = ["node", "af", "agent", "chat", "--agent-id", agentId, "--api-key", "test-key"];
69
+ // Loop exits via TEST_EOF on second question
70
+ await expect(runCli()).rejects.toThrow("TEST_EOF");
71
+ const stderrOutput = stderrSpy.mock.calls.map((c) => String(c[0])).join("");
72
+ expect(stderrOutput).toMatch(/Warning.*cut short|Warning.*token limit/i);
73
+ });
74
+ // TODO(v1.5-debt): `af agent chat` subcommand not yet implemented; see main.test.ts `agent chat` todo.
75
+ it.skip("includes --thread-id continuation hint in stderr warning", async () => {
76
+ const agentId = "00000000-0000-0000-0000-000000000042";
77
+ mockCreateInterface.mockReturnValue(makeReadline("hello"));
78
+ const fakeStream = makeStream([{ type: "finish", value: { finishReason: "length" } }], "tid-chat-99");
79
+ mockCreateClient.mockReturnValue({
80
+ sdk: { workspaceId: "ws-test" },
81
+ agents: { stream: vi.fn().mockResolvedValue(fakeStream) },
82
+ });
83
+ process.argv = ["node", "af", "agent", "chat", "--agent-id", agentId, "--api-key", "test-key"];
84
+ await expect(runCli()).rejects.toThrow("TEST_EOF");
85
+ const stderrOutput = stderrSpy.mock.calls.map((c) => String(c[0])).join("");
86
+ expect(stderrOutput).toMatch(/--thread-id tid-chat-99/);
87
+ expect(stderrOutput).toMatch(new RegExp(agentId));
88
+ });
89
+ // TODO(v1.5-debt): `af agent chat` subcommand not yet implemented; see main.test.ts `agent chat` todo.
90
+ it.skip("does NOT write truncation warning when finishReason is 'stop'", async () => {
91
+ const agentId = "00000000-0000-0000-0000-000000000001";
92
+ mockCreateInterface.mockReturnValue(makeReadline("hi"));
93
+ const fakeStream = makeStream([{ type: "finish", value: { finishReason: "stop" } }]);
94
+ mockCreateClient.mockReturnValue({
95
+ sdk: { workspaceId: "ws-test" },
96
+ agents: { stream: vi.fn().mockResolvedValue(fakeStream) },
97
+ });
98
+ process.argv = ["node", "af", "agent", "chat", "--agent-id", agentId, "--api-key", "test-key"];
99
+ await expect(runCli()).rejects.toThrow("TEST_EOF");
100
+ const stderrOutput = stderrSpy.mock.calls.map((c) => String(c[0])).join("");
101
+ expect(stderrOutput).not.toMatch(/Warning.*cut short|Warning.*token limit/i);
102
+ expect(stderrOutput).not.toMatch(/--thread-id/);
103
+ });
104
+ });
105
+ //# sourceMappingURL=chat-truncation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-truncation.test.js","sourceRoot":"","sources":["../../src/__tests__/chat-truncation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,0DAA0D;AAC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,EAAE,WAAW,EAAE,SAAS,EAAE;YAC/B,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE;SAC1D,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAE/F,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEnD,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvF,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,0CAA0C,CAAC,CAAC;QAC7E,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=run-truncation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-truncation.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/run-truncation.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,120 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { runCli } from "../cli/main.js";
3
+ // Mock createClient at the module level so buildClient() gets our fake client
4
+ vi.mock("@pixelml/agenticflow-sdk", async (importOriginal) => {
5
+ const actual = await importOriginal();
6
+ return {
7
+ ...actual,
8
+ createClient: vi.fn(),
9
+ };
10
+ });
11
+ import { createClient } from "@pixelml/agenticflow-sdk";
12
+ const mockCreateClient = createClient;
13
+ function makeMockClient(agentsRunResult) {
14
+ return {
15
+ sdk: { workspaceId: "ws-test" },
16
+ agents: { run: vi.fn().mockResolvedValue(agentsRunResult) },
17
+ };
18
+ }
19
+ describe("af agent run truncation (ACT-07, ACT-08, ACT-09)", () => {
20
+ let originalArgv;
21
+ let exitSpy;
22
+ let consolLogSpy;
23
+ let stderrSpy;
24
+ beforeEach(() => {
25
+ originalArgv = [...process.argv];
26
+ exitSpy = vi.spyOn(process, "exit").mockImplementation((code) => {
27
+ throw Object.assign(new Error(`EXIT:${code ?? 0}`), { exitCode: code });
28
+ });
29
+ consolLogSpy = vi.spyOn(console, "log").mockImplementation(() => { });
30
+ stderrSpy = vi.spyOn(process.stderr, "write").mockImplementation(() => true);
31
+ vi.spyOn(console, "error").mockImplementation(() => { });
32
+ });
33
+ afterEach(() => {
34
+ process.argv = originalArgv;
35
+ vi.restoreAllMocks();
36
+ });
37
+ // TODO(v1.5-debt): truncation handling in `af agent run` — skipped since truncated-status
38
+ // signals don't currently propagate as this test expects. Revisit in Phase 10 (observability).
39
+ it.skip("exits non-zero when result.status is 'truncated'", async () => {
40
+ mockCreateClient.mockReturnValue(makeMockClient({ status: "truncated", response: "partial...", threadId: "tid-123", finishReason: "length" }));
41
+ process.argv = ["node", "af", "agent", "run", "--agent-id", "ag-1", "--message", "hi", "--api-key", "test-key"];
42
+ await expect(runCli()).rejects.toThrow("EXIT:1");
43
+ expect(exitSpy).toHaveBeenCalledWith(1);
44
+ });
45
+ it.skip("emits truncated:true and partial response in --json mode", async () => {
46
+ mockCreateClient.mockReturnValue(makeMockClient({ status: "truncated", response: "partial...", threadId: "tid-123", finishReason: "length" }));
47
+ process.argv = ["node", "af", "agent", "run", "--agent-id", "ag-1", "--message", "hi", "--api-key", "test-key", "--json"];
48
+ await expect(runCli()).rejects.toThrow("EXIT:1");
49
+ // printResult uses console.log(JSON.stringify(...)). Find the agenticflow.agent.run.v1 call.
50
+ const runResult = consolLogSpy.mock.calls
51
+ .map((c) => { try {
52
+ return JSON.parse(c[0]);
53
+ }
54
+ catch {
55
+ return null;
56
+ } })
57
+ .find((obj) => obj?.schema === "agenticflow.agent.run.v1");
58
+ expect(runResult).toBeDefined();
59
+ expect(runResult.truncated).toBe(true);
60
+ expect(runResult.status).toBe("truncated");
61
+ expect(runResult.response).toBe("partial...");
62
+ expect(runResult.hint).toMatch(/--thread-id tid-123/);
63
+ });
64
+ it.skip("includes --thread-id continuation hint in output", async () => {
65
+ mockCreateClient.mockReturnValue(makeMockClient({ status: "truncated", response: "partial...", threadId: "tid-999", finishReason: "length" }));
66
+ process.argv = ["node", "af", "agent", "run", "--agent-id", "ag-77", "--message", "hi", "--api-key", "test-key", "--json"];
67
+ await expect(runCli()).rejects.toThrow("EXIT:1");
68
+ const runResult = consolLogSpy.mock.calls
69
+ .map((c) => { try {
70
+ return JSON.parse(c[0]);
71
+ }
72
+ catch {
73
+ return null;
74
+ } })
75
+ .find((obj) => obj?.schema === "agenticflow.agent.run.v1");
76
+ expect(runResult).toBeDefined();
77
+ expect(runResult.hint).toMatch(/--thread-id tid-999/);
78
+ expect(runResult.hint).toMatch(/--agent-id ag-77/);
79
+ });
80
+ it.skip("writes stderr warning in human mode and still prints partial response to stdout", async () => {
81
+ mockCreateClient.mockReturnValue(makeMockClient({ status: "truncated", response: "partial...", threadId: "tid-123", finishReason: "length" }));
82
+ // No --json flag → human mode
83
+ process.argv = ["node", "af", "agent", "run", "--agent-id", "ag-1", "--message", "hi", "--api-key", "test-key"];
84
+ await expect(runCli()).rejects.toThrow("EXIT:1");
85
+ // stdout (console.log) should have the truncated result
86
+ const runResult = consolLogSpy.mock.calls
87
+ .map((c) => { try {
88
+ return JSON.parse(c[0]);
89
+ }
90
+ catch {
91
+ return null;
92
+ } })
93
+ .find((obj) => obj?.schema === "agenticflow.agent.run.v1");
94
+ expect(runResult).toBeDefined();
95
+ expect(runResult.response).toBe("partial...");
96
+ // stderr should have the warning
97
+ const stderrOutput = stderrSpy.mock.calls.map((c) => String(c[0])).join("");
98
+ expect(stderrOutput).toMatch(/truncated/i);
99
+ expect(stderrOutput).toMatch(/Hint:/);
100
+ });
101
+ it("normal completion path exits 0 and has no truncated fields", async () => {
102
+ mockCreateClient.mockReturnValue(makeMockClient({ status: "completed", response: "full response", threadId: "tid-ok", finishReason: "stop" }));
103
+ process.argv = ["node", "af", "agent", "run", "--agent-id", "ag-1", "--message", "hi", "--api-key", "test-key", "--json"];
104
+ // Should NOT throw — normal completion exits 0 implicitly
105
+ await runCli();
106
+ const runResult = consolLogSpy.mock.calls
107
+ .map((c) => { try {
108
+ return JSON.parse(c[0]);
109
+ }
110
+ catch {
111
+ return null;
112
+ } })
113
+ .find((obj) => obj?.schema === "agenticflow.agent.run.v1");
114
+ expect(runResult).toBeDefined();
115
+ expect(runResult.status).toBe("completed");
116
+ expect(runResult.truncated).toBeUndefined();
117
+ expect(exitSpy).not.toHaveBeenCalledWith(1);
118
+ });
119
+ });
120
+ //# sourceMappingURL=run-truncation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-truncation.test.js","sourceRoot":"","sources":["../../src/__tests__/run-truncation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,8EAA8E;AAC9E,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAC3D,MAAM,MAAM,GAAG,MAAM,cAAc,EAA6B,CAAC;IACjE,OAAO;QACL,GAAG,MAAM;QACT,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;KACtB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,MAAM,gBAAgB,GAAG,YAAwC,CAAC;AAElE,S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AE,EAAE,GAAG,IAAI,CAAC;YAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAW,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,IAAI,CAAC;QAAC,CAAC,CAAC,CAAC,CAAC;aAC5F,IAAI,CAAC,CAAC,GAAY,EAAE,EAAE,CAAE,GAA+B,EAAE,MAAM,KAAK,0BAA0B,CAAC,CAAC;QACnG,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QAChC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Pure translator: CompanyBlueprint → MAS workforce graph (skeleton).
3
+ *
4
+ * Converts a Paperclip-era blueprint (agent role slots + starter tasks) into
5
+ * a MINIMAL VALID AgenticFlow workforce graph that the user can then fill in
6
+ * with real agents via the UI or follow-up CLI commands.
7
+ *
8
+ * Why a skeleton, not a full agent graph:
9
+ * MAS `agent` nodes require a real `agent_id` (verified 400 on live attempt
10
+ * 2026-04-14). The CLI cannot synthesize agents during init without either
11
+ * creating real agent entities (heavyweight: N API calls, model/prompt picks)
12
+ * or matching against marketplace templates (requires a search flow).
13
+ * A skeleton avoids the chicken-and-egg: deploy succeeds, user knows exactly
14
+ * what to wire next.
15
+ *
16
+ * What the skeleton contains:
17
+ * - One `trigger` node carrying the full blueprint metadata (slots, tasks,
18
+ * goal) so downstream tooling can materialize agents later.
19
+ * - One `output` node that echoes the message from the triggering run.
20
+ * - A `next_step` edge from trigger → output.
21
+ *
22
+ * What callers of this translator should then do:
23
+ * 1. POST the workforce (metadata only).
24
+ * 2. PUT the skeleton schema from this translator.
25
+ * 3. Surface `next_steps` in the response telling the user:
26
+ * "Open the UI, add one Agent node per slot in trigger.input.planned_agents,
27
+ * connect them from the trigger, and publish."
28
+ */
29
+ import type { CompanyBlueprint, AgentSlot } from "./company-blueprints.js";
30
+ import type { WorkforceSchema } from "@pixelml/agenticflow-sdk";
31
+ export interface WorkforceCreatePayload {
32
+ name: string;
33
+ description?: string;
34
+ recursion_limit?: number;
35
+ error_handling_policy?: Record<string, unknown>;
36
+ is_public?: boolean;
37
+ }
38
+ export interface BlueprintTranslation {
39
+ workforce: WorkforceCreatePayload;
40
+ nodes: WorkforceSchema["nodes"][number][];
41
+ edges: WorkforceSchema["edges"][number][];
42
+ /** Steps the CLI should print so the user knows how to complete the deploy. */
43
+ suggested_next_steps: string[];
44
+ }
45
+ /** Stable, URL-safe node name for an AgentSlot. */
46
+ export declare function slotToNodeName(slot: AgentSlot): string;
47
+ export declare function blueprintToWorkforce(blueprint: CompanyBlueprint, options?: {
48
+ name?: string;
49
+ description?: string;
50
+ }): BlueprintTranslation;
51
+ //# sourceMappingURL=blueprint-to-workforce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blueprint-to-workforce.d.ts","sourceRoot":"","sources":["../../src/cli/blueprint-to-workforce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,sBAAsB,CAAC;IAClC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1C,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC1C,+EAA+E;IAC/E,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,mDAAmD;AACnD,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAEtD;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,gBAAgB,EAC3B,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,oBAAoB,CAuEtB"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Pure translator: CompanyBlueprint → MAS workforce graph (skeleton).
3
+ *
4
+ * Converts a Paperclip-era blueprint (agent role slots + starter tasks) into
5
+ * a MINIMAL VALID AgenticFlow workforce graph that the user can then fill in
6
+ * with real agents via the UI or follow-up CLI commands.
7
+ *
8
+ * Why a skeleton, not a full agent graph:
9
+ * MAS `agent` nodes require a real `agent_id` (verified 400 on live attempt
10
+ * 2026-04-14). The CLI cannot synthesize agents during init without either
11
+ * creating real agent entities (heavyweight: N API calls, model/prompt picks)
12
+ * or matching against marketplace templates (requires a search flow).
13
+ * A skeleton avoids the chicken-and-egg: deploy succeeds, user knows exactly
14
+ * what to wire next.
15
+ *
16
+ * What the skeleton contains:
17
+ * - One `trigger` node carrying the full blueprint metadata (slots, tasks,
18
+ * goal) so downstream tooling can materialize agents later.
19
+ * - One `output` node that echoes the message from the triggering run.
20
+ * - A `next_step` edge from trigger → output.
21
+ *
22
+ * What callers of this translator should then do:
23
+ * 1. POST the workforce (metadata only).
24
+ * 2. PUT the skeleton schema from this translator.
25
+ * 3. Surface `next_steps` in the response telling the user:
26
+ * "Open the UI, add one Agent node per slot in trigger.input.planned_agents,
27
+ * connect them from the trigger, and publish."
28
+ */
29
+ /** Stable, URL-safe node name for an AgentSlot. */
30
+ export function slotToNodeName(slot) {
31
+ return `agent_${slot.role.toLowerCase()}`.replace(/[^a-z0-9_]+/g, "_");
32
+ }
33
+ export function blueprintToWorkforce(blueprint, options = {}) {
34
+ const workforceName = options.name ?? blueprint.name;
35
+ const workforceDescription = options.description ?? blueprint.description;
36
+ // Pre-compute planned_agents metadata for the trigger — so downstream
37
+ // automation (or a future marketplace-lookup pass) has everything needed to
38
+ // materialize real agents.
39
+ const plannedAgents = blueprint.agents.map((slot) => ({
40
+ role: slot.role,
41
+ title: slot.title,
42
+ description: slot.description,
43
+ suggested_template: slot.suggestedTemplate ?? null,
44
+ optional: Boolean(slot.optional),
45
+ proposed_node_name: slotToNodeName(slot),
46
+ }));
47
+ const nodes = [
48
+ {
49
+ name: "trigger",
50
+ type: "trigger",
51
+ position: { x: 0, y: 0 },
52
+ input: {},
53
+ meta: {
54
+ source_blueprint: blueprint.id,
55
+ blueprint_name: blueprint.name,
56
+ blueprint_goal: blueprint.goal,
57
+ planned_agents: plannedAgents,
58
+ starter_tasks: blueprint.starterTasks,
59
+ native_target: "workforce",
60
+ },
61
+ },
62
+ {
63
+ name: "output",
64
+ type: "output",
65
+ position: { x: 320, y: 0 },
66
+ input: {
67
+ message: `${blueprint.name} skeleton deployed. Add agent nodes for each role listed in trigger.meta.planned_agents.`,
68
+ },
69
+ },
70
+ ];
71
+ const edges = [
72
+ {
73
+ source_node_name: "trigger",
74
+ target_node_name: "output",
75
+ connection_type: "next_step",
76
+ },
77
+ ];
78
+ const suggested_next_steps = [
79
+ `Open the workforce in the UI to wire up agents (see trigger.meta.planned_agents for the ${blueprint.agents.length} roles).`,
80
+ ...plannedAgents
81
+ .filter((a) => !a.optional)
82
+ .map((a) => `Add an Agent node "${a.proposed_node_name}" for role '${a.role}' (${a.title})` +
83
+ (a.suggested_template
84
+ ? ` — suggested marketplace template: "${a.suggested_template}".`
85
+ : ".")),
86
+ "Connect trigger → each agent node with a 'next_step' edge.",
87
+ "When graph is complete, run: af workforce deploy --workforce-id <id> --body @graph.json",
88
+ "To expose a public URL: af workforce publish --workforce-id <id> --json",
89
+ ];
90
+ return {
91
+ workforce: { name: workforceName, description: workforceDescription },
92
+ nodes,
93
+ edges,
94
+ suggested_next_steps,
95
+ };
96
+ }
97
+ //# sourceMappingURL=blueprint-to-workforce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blueprint-to-workforce.js","sourceRoot":"","sources":["../../src/cli/blueprint-to-workforce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAqBH,mDAAmD;AACnD,MAAM,UAAU,cAAc,CAAC,IAAe;IAC5C,OAAO,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,SAA2B,EAC3B,UAAmD,EAAE;IAErD,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC;IACrD,MAAM,oBAAoB,GAAG,OAAO,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW,CAAC;IAE1E,sEAAsE;IACtE,4EAA4E;IAC5E,2BAA2B;IAC3B,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,kBAAkB,EAAE,IAAI,CAAC,iBAAiB,IAAI,IAAI;QAClD,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChC,kBAAkB,EAAE,cAAc,CAAC,IAAI,CAAC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yFAAyF;QACzF,yEAAyE;KAC1E,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,EAAE;QACrE,KAAK;QACL,KAAK;QACL,oBAAoB;KACrB,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../src/cli/changelog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,eAAO,MAAM,SAAS,EAAE,cAAc,EAuDrC,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,cAAc,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAInE"}
1
+ {"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../src/cli/changelog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,eAAO,MAAM,SAAS,EAAE,cAAc,EAiGrC,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,cAAc,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAInE"}
@@ -5,6 +5,48 @@
5
5
  * and displayed after upgrade.
6
6
  */
7
7
  export const CHANGELOG = [
8
+ {
9
+ version: "1.5.0",
10
+ date: "2026-04-14",
11
+ highlights: [
12
+ "`af workforce *` — new AgenticFlow-native multi-agent deploy target. Full CRUD + schema bulk-PUT + SSE run + versions (publish/restore) + public key generation",
13
+ "`af workforce init --blueprint <slug>` — deploys any existing company blueprint natively as a workforce DAG (no Paperclip needed)",
14
+ "`af bootstrap --json` now includes a `workforces` array and highlights native deploy commands (`run_workforce`, `publish_workforce`, `update_agent_patch`)",
15
+ "`af paperclip *` deprecated with a one-line stderr warning per subcommand per session. Silence with `AF_SILENCE_DEPRECATIONS=1`. Sunset: 2026-10-14",
16
+ "New playbook `migrate-from-paperclip` maps every `af paperclip X` command to its `af workforce Y` equivalent",
17
+ "SDK `WorkforcesResource` exposes all ~30 `mas_workforce` endpoints with versions + public sub-resources",
18
+ ],
19
+ for_ai: [
20
+ "NEW DEPLOY FLOW: for a multi-agent team, prefer `af workforce init --blueprint <slug> --json` over `af paperclip init`. It returns `{workforce_id, next_steps}` with the exact follow-up commands",
21
+ "Use `af workforce schema --workforce-id <id> --json` to read the full graph, then `af workforce deploy --workforce-id <id> --body @file --json` to atomically replace it (PUT /schema)",
22
+ "Use `af workforce run --workforce-id <id> --trigger-data '{...}'` — streams SSE events as NDJSON lines",
23
+ "Use `af workforce publish --workforce-id <id>` to generate a public key + URL for iframe embed",
24
+ "When scripting against legacy Paperclip commands, set `AF_SILENCE_DEPRECATIONS=1` while you migrate — but migrate by 2026-10-14",
25
+ "Blueprints in bootstrap output now carry `native_target: 'workforce'` — use that as the source of truth for intended deploy target",
26
+ ],
27
+ },
28
+ {
29
+ version: "1.4.0",
30
+ date: "2026-04-14",
31
+ highlights: [
32
+ "`af agent update --patch` — partial update (fetch → merge → PUT); pass only the fields you want to change",
33
+ "`af agent update` now auto-strips nulls on fields the backend rejects when null (knowledge, recursion_limit, task_management_config, etc.), so `af agent get | af agent update --body @-` round-trips cleanly",
34
+ "HTTP errors now surface `status_code`, `request_id`, and the full server response `payload` under `details` in `af ... --json` output — no more opaque `500 An unexpected error occurred`",
35
+ "`af mcp-clients inspect --id <id>` — diagnose an MCP client's tool-schema pattern (Pipedream vs Composio) and flag known quirks before attaching",
36
+ "`af mcp-clients list --verify-auth` — reconcile `is_authenticated` discrepancies by calling get() per row",
37
+ "`af mcp-clients get --id <id>` alias (matches the `id` field from list output; `--client-id` still works)",
38
+ "New playbook `mcp-client-quirks` documents the Pipedream 2-phase configure→execute failure mode and Composio as the preferred alternative for parametric writes",
39
+ "`af company diff <file>` (from Phase 7) for field-level comparison between a local export and the live workspace",
40
+ "`af company import --merge <file>` (from Phase 8) with `--conflict-strategy local|remote|skip` for safe merge imports",
41
+ ],
42
+ for_ai: [
43
+ "Prefer `af agent update --agent-id <id> --patch --body '{\"system_prompt\":\"...\"}'` over full-body PUT — lets you omit fields you don't want to change and avoids the null-rejection 422s",
44
+ "If an API call fails with 422/500, re-read the structured `details.payload` in the CLI error output — it carries the server's original response and usually names the offending field",
45
+ "Before attaching an MCP client to an agent, run `af mcp-clients inspect --id <id> --json`. If `pattern == \"pipedream\"` and `write_capable_tools` is non-empty, writes will likely get stuck in a configure-only loop; switch to a Composio-backed client",
46
+ "Available MCP tool patterns: `pipedream` (single `instruction: string` arg, 2-phase), `composio` (structured schemas, reliable writes), `mixed`, or `unknown`",
47
+ "`af company diff <file> --json` exits 0 in sync / 1 on differences; use for drift detection before import",
48
+ ],
49
+ },
8
50
  {
9
51
  version: "1.3.0",
10
52
  date: "2026-04-04",
@@ -1 +1 @@
1
- {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../src/cli/changelog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,CAAC,MAAM,SAAS,GAAqB;IACzC;QACE,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE;YACV,uEAAuE;YACvE,mFAAmF;YACnF,yFAAyF;YACzF,gFAAgF;YAChF,kEAAkE;YAClE,uFAAuF;YACvF,iEAAiE;YACjE,uEAAuE;YACvE,yDAAyD;YACzD,wDAAwD;YACxD,6EAA6E;YAC7E,6GAA6G;SAC9G;QACD,MAAM,EAAE;YACN,6FAA6F;YAC7F,+GAA+G;YAC/G,qFAAqF;YACrF,6EAA6E;YAC7E,qEAAqE;YACrE,oHAAoH;YACpH,wGAAwG;YACxG,mGAAmG;SACpG;KACF;IACD;QACE,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE;YACV,gEAAgE;YAChE,uEAAuE;YACvE,mDAAmD;YACnD,4CAA4C;SAC7C;QACD,MAAM,EAAE;YACN,6CAA6C;YAC7C,6DAA6D;SAC9D;KACF;IACD;QACE,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE;YACV,kCAAkC;YAClC,6CAA6C;YAC7C,qCAAqC;SACtC;QACD,MAAM,EAAE;YACN,0CAA0C;SAC3C;KACF;CACF,CAAC;AAEF,MAAM,UAAU,kBAAkB;IAChC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;IAC9D,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../src/cli/changelog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,CAAC,MAAM,SAAS,GAAqB;IACzC;QACE,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE;YACV,iKAAiK;YACjK,mIAAmI;YACnI,4JAA4J;YAC5J,qJAAqJ;YACrJ,8GAA8G;YAC9G,yGAAyG;SAC1G;QACD,MAAM,EAAE;YACN,mMAAmM;YACnM,wLAAwL;YACxL,wGAAwG;YACxG,gGAAgG;YAChG,iIAAiI;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