patchwork-os 0.2.0-beta.8.canary.73 → 0.2.0-beta.8.canary.74

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.
@@ -22,11 +22,24 @@
22
22
  */
23
23
  import type { Recipe } from "./schema.js";
24
24
  /**
25
- * Tool-name prefix → connector id (matching the IDs returned by
25
+ * Tool-namespace → connector id (matching the IDs returned by
26
26
  * `/connections` — see src/connectors/gmail.ts handleConnectionsList).
27
27
  * Both `google-calendar` and the dashboard's `googleCalendar` spelling
28
28
  * are accepted on the caller side; this map is authoritative for the
29
29
  * bridge.
30
+ *
31
+ * Keys are BARE namespace names (no separator). The matcher accepts BOTH
32
+ * dot-form (`slack.post_message`) and underscore-form (`slack_post_message`)
33
+ * tool IDs. Real registry tools use dot-form
34
+ * (e.g. `src/recipes/tools/slack.ts` registers `slack.post_message`); the
35
+ * previous map keyed by `slack_` etc. silently failed every YAML recipe
36
+ * install because `tool.startsWith("slack_")` never matched `slack.post_message`.
37
+ */
38
+ export declare const TOOL_NAMESPACE_TO_CONNECTOR: Record<string, string>;
39
+ /**
40
+ * @deprecated Use `TOOL_NAMESPACE_TO_CONNECTOR` instead. Kept as a thin
41
+ * alias derived from the canonical map so legacy callers (and the
42
+ * underscore-suffix tool-name shape) keep working until they migrate.
30
43
  */
31
44
  export declare const TOOL_PREFIX_TO_CONNECTOR: Record<string, string>;
32
45
  /**
@@ -1,31 +1,58 @@
1
1
  /**
2
- * Tool-name prefix → connector id (matching the IDs returned by
2
+ * Tool-namespace → connector id (matching the IDs returned by
3
3
  * `/connections` — see src/connectors/gmail.ts handleConnectionsList).
4
4
  * Both `google-calendar` and the dashboard's `googleCalendar` spelling
5
5
  * are accepted on the caller side; this map is authoritative for the
6
6
  * bridge.
7
+ *
8
+ * Keys are BARE namespace names (no separator). The matcher accepts BOTH
9
+ * dot-form (`slack.post_message`) and underscore-form (`slack_post_message`)
10
+ * tool IDs. Real registry tools use dot-form
11
+ * (e.g. `src/recipes/tools/slack.ts` registers `slack.post_message`); the
12
+ * previous map keyed by `slack_` etc. silently failed every YAML recipe
13
+ * install because `tool.startsWith("slack_")` never matched `slack.post_message`.
7
14
  */
8
- export const TOOL_PREFIX_TO_CONNECTOR = {
9
- slack_: "slack",
10
- github_: "github",
11
- jira_: "jira",
12
- linear_: "linear",
13
- gmail_: "gmail",
14
- calendar_: "google-calendar",
15
- drive_: "google-drive",
16
- intercom_: "intercom",
17
- hubspot_: "hubspot",
18
- datadog_: "datadog",
19
- stripe_: "stripe",
20
- sentry_: "sentry",
21
- zendesk_: "zendesk",
22
- asana_: "asana",
23
- notion_: "notion",
24
- confluence_: "confluence",
25
- discord_: "discord",
26
- gitlab_: "gitlab",
27
- pagerduty_: "pagerduty",
15
+ export const TOOL_NAMESPACE_TO_CONNECTOR = {
16
+ slack: "slack",
17
+ github: "github",
18
+ jira: "jira",
19
+ linear: "linear",
20
+ gmail: "gmail",
21
+ calendar: "google-calendar",
22
+ drive: "google-drive",
23
+ intercom: "intercom",
24
+ hubspot: "hubspot",
25
+ datadog: "datadog",
26
+ stripe: "stripe",
27
+ sentry: "sentry",
28
+ zendesk: "zendesk",
29
+ asana: "asana",
30
+ notion: "notion",
31
+ confluence: "confluence",
32
+ discord: "discord",
33
+ gitlab: "gitlab",
34
+ pagerduty: "pagerduty",
28
35
  };
36
+ /**
37
+ * @deprecated Use `TOOL_NAMESPACE_TO_CONNECTOR` instead. Kept as a thin
38
+ * alias derived from the canonical map so legacy callers (and the
39
+ * underscore-suffix tool-name shape) keep working until they migrate.
40
+ */
41
+ export const TOOL_PREFIX_TO_CONNECTOR = Object.fromEntries(Object.entries(TOOL_NAMESPACE_TO_CONNECTOR).map(([ns, connector]) => [
42
+ `${ns}_`,
43
+ connector,
44
+ ]));
45
+ /**
46
+ * Extract the namespace prefix from a registered tool ID. Tool IDs land
47
+ * in either `namespace.tool_name` (the canonical dot-form used by every
48
+ * registry entry today — see `src/recipes/tools/*.ts`) or the older
49
+ * `namespace_tool_name` underscore-form some tests use. Either form
50
+ * resolves to the bare namespace, lowercased.
51
+ */
52
+ function extractNamespace(toolId) {
53
+ const m = toolId.match(/^([a-z][a-z0-9-]*)[_.]/i);
54
+ return m?.[1]?.toLowerCase();
55
+ }
29
56
  function toolsOfStep(step) {
30
57
  // agent: false steps carry a single `tool` field. agent: true steps
31
58
  // optionally list permitted tools in `tools[]`. Other shapes (nested
@@ -44,13 +71,8 @@ function toolsOfStep(step) {
44
71
  * source map is small and stable, so caching this avoids regex churn
45
72
  * inside the per-step loop.
46
73
  */
47
- const PROMPT_PREFIX_PATTERNS = Object.entries(TOOL_PREFIX_TO_CONNECTOR).map(([prefix, connector]) => ({
48
- // Strip trailing underscore — when the prompt mentions a tool name like
49
- // `slack_post_message` the underscore is part of the literal we look
50
- // for, but when an agent prompt is more conversational ("post to slack
51
- // using slack.post_message"), we want to match the prefix without the
52
- // separator too.
53
- prefix: prefix.replace(/_$/, ""),
74
+ const PROMPT_PREFIX_PATTERNS = Object.entries(TOOL_NAMESPACE_TO_CONNECTOR).map(([prefix, connector]) => ({
75
+ prefix,
54
76
  connector,
55
77
  }));
56
78
  /**
@@ -100,11 +122,15 @@ export function detectRequiredConnectors(recipe) {
100
122
  const required = new Set();
101
123
  for (const step of recipe.steps) {
102
124
  // Explicit `tool` / `tools[]` fields (canonical detection path).
125
+ // Pull the namespace out of the tool ID — works for both dot-form
126
+ // (the registry's canonical `slack.post_message`) and the legacy
127
+ // underscore-form some tests use (`slack_post_message`).
103
128
  for (const tool of toolsOfStep(step)) {
104
- for (const [prefix, connector] of Object.entries(TOOL_PREFIX_TO_CONNECTOR)) {
105
- if (tool.startsWith(prefix)) {
129
+ const ns = extractNamespace(tool);
130
+ if (ns) {
131
+ const connector = TOOL_NAMESPACE_TO_CONNECTOR[ns];
132
+ if (connector)
106
133
  required.add(connector);
107
- }
108
134
  }
109
135
  }
110
136
  // Prompt body scan for agent-mode steps — catches recipes that
@@ -1 +1 @@
1
- {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AC;QACD,+DAA+D;QAC/D,uEAAuE;QACvE,gDAAgD;QAChD,sDAAsD;QACtD,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC3D,KAAK,MAAM,SAAS,IAAI,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9D,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC;AAOD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAA+B,EAC/B,WAAgD;IAEhD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,EAAE,EAAE,KAAK,QAAQ;YAAE,SAAS;QACxC,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW;YAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchwork-os",
3
- "version": "0.2.0-beta.8.canary.73",
3
+ "version": "0.2.0-beta.8.canary.74",
4
4
  "description": "Your personal AI runtime, local-first. Patchwork OS gives any AI model a consistent set of tools, YAML recipes, a delegation policy with approval queue, and a durable trace memory — all on your machine, all under your policy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",