@ekanos/sdk 0.1.2 → 0.1.4

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 (58) hide show
  1. package/README.md +1165 -140
  2. package/api-report.md +206 -0
  3. package/dist/components/index.d.ts +3 -2
  4. package/dist/components/index.js +3 -2
  5. package/dist/components/index.js.map +1 -1
  6. package/dist/components/widgets/widget-context.js.map +1 -1
  7. package/dist/context/index.d.ts +1 -1
  8. package/dist/context/index.js +1 -1
  9. package/dist/context/index.js.map +1 -1
  10. package/dist/context/types.d.ts +1 -1
  11. package/dist/context/types.js.map +1 -1
  12. package/dist/hooks/activation-actions-context.d.ts +4 -4
  13. package/dist/hooks/activation-actions-context.js +1 -1
  14. package/dist/hooks/activation-actions-context.js.map +1 -1
  15. package/dist/hooks/index.d.ts +2 -2
  16. package/dist/hooks/index.js +2 -2
  17. package/dist/hooks/index.js.map +1 -1
  18. package/dist/hooks/use-oauth-connection-status.d.ts +18 -72
  19. package/dist/hooks/use-oauth-connection-status.js +1 -1
  20. package/dist/hooks/use-oauth-connection-status.js.map +1 -1
  21. package/dist/index.d.ts +3 -2
  22. package/dist/index.js +3 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/integration/define-integration.d.ts +2 -3
  25. package/dist/integration/define-integration.js +2 -3
  26. package/dist/integration/define-integration.js.map +1 -1
  27. package/dist/integration/index.d.ts +3 -3
  28. package/dist/integration/index.js +2 -2
  29. package/dist/integration/index.js.map +1 -1
  30. package/dist/integration/types.d.ts +1 -1
  31. package/dist/integration/types.js.map +1 -1
  32. package/dist/testing/index.d.ts +3 -3
  33. package/dist/testing/index.js +4 -3
  34. package/dist/testing/index.js.map +1 -1
  35. package/dist/testing/invoke.d.ts +25 -1
  36. package/dist/testing/invoke.js +19 -0
  37. package/dist/testing/invoke.js.map +1 -1
  38. package/dist/types/index.d.ts +3 -4
  39. package/dist/types/index.js +3 -4
  40. package/dist/types/index.js.map +1 -1
  41. package/dist/types/integration.d.ts +2 -2
  42. package/dist/types/integration.js.map +1 -1
  43. package/dist/types/widget-ask-context.d.ts +1 -1
  44. package/dist/types/widget-ask-context.js.map +1 -1
  45. package/eslint.preset.mjs +2 -4
  46. package/package.json +14 -16
  47. package/dist/mcp/guards.d.ts +0 -40
  48. package/dist/mcp/guards.js +0 -99
  49. package/dist/mcp/guards.js.map +0 -1
  50. package/dist/mcp/index.d.ts +0 -22
  51. package/dist/mcp/index.js +0 -22
  52. package/dist/mcp/index.js.map +0 -1
  53. package/dist/mcp/ownership.d.ts +0 -74
  54. package/dist/mcp/ownership.js +0 -83
  55. package/dist/mcp/ownership.js.map +0 -1
  56. package/dist/mcp/types.d.ts +0 -145
  57. package/dist/mcp/types.js +0 -2
  58. package/dist/mcp/types.js.map +0 -1
@@ -1,145 +0,0 @@
1
- import type { SupabaseClient } from '@supabase/supabase-js';
2
- import type { IntegrationContext } from '@ekanos/integration-schema';
3
- export type ToolParamsSchema = {
4
- type: 'object';
5
- properties?: Record<string, unknown>;
6
- required?: string[];
7
- additionalProperties?: boolean;
8
- };
9
- export type ToolContext = {
10
- req: Request;
11
- /**
12
- * Admin Supabase client for in-process MCP execution.
13
- * This bypasses RLS; tools must perform their own authorization checks before
14
- * reading or mutating protected data.
15
- */
16
- supabase: SupabaseClient;
17
- user: {
18
- id: string;
19
- } & Record<string, unknown>;
20
- /** The resolved account slug from the workspace context (injected by MCP route) */
21
- accountSlug?: string;
22
- /** The resolved account ID (UUID) from the workspace context (injected by MCP route) */
23
- accountId?: string;
24
- /** The resolved source ID (UUID) for the current tenant/workspace */
25
- sourceId?: string | null;
26
- /** The user's resolved IANA timezone (e.g. 'America/New_York') */
27
- timezone?: string;
28
- /** Whether the authenticated user is a platform super-admin */
29
- isSuperAdmin?: boolean;
30
- /**
31
- * Who is executing this tool call.
32
- *
33
- * Undefined (the default for every user-facing MCP path) is treated as
34
- * `'user'` — the historical behavior. `'machine'` marks a non-interactive
35
- * caller (the Workflow Gateway) whose identity IS the account-bound gateway
36
- * token, not a signed-in session. See machineGrant below and the
37
- * "Machine-principal design" section of context/N8N_INTEGRATION_PLAN.md.
38
- */
39
- principal?: 'user' | 'machine';
40
- /**
41
- * Present only when `principal === 'machine'`. Carries the account the
42
- * gateway token is bound to (the sole source of account identity for a
43
- * machine call), the token row id, and the token creator for audit
44
- * attribution. `getAccountId` / `ensureAccountMembership` read this instead
45
- * of doing a DB membership lookup — the token itself is the authorization.
46
- */
47
- machineGrant?: {
48
- accountId: string;
49
- tokenId: string;
50
- createdBy: string | null;
51
- };
52
- /**
53
- * The host-built capability context
54
- * (docs/devex/capability-context-proposal.md), attached ADDITIVELY by the
55
- * MCP route after authorization. This is the CANONICAL `IntegrationContext`
56
- * from `@ekanos/integration-schema` — the same declaration `@ekanos/sdk`
57
- * re-exports, so there is no structural twin to drift and no core→SDK
58
- * package cycle. Migrated tools may still narrow it with
59
- * `requireContext(ctx)` from `@ekanos/sdk/context`; existing tools that
60
- * never touch this field are unaffected.
61
- */
62
- integrationContext?: IntegrationContext;
63
- };
64
- export type ToolRunResult = unknown;
65
- /**
66
- * The partner execution channel — the ONLY way partner-authored tool code
67
- * runs (capability-context proposal §3 + sdk-export-map.md adversarial
68
- * review outcomes 1–2).
69
- *
70
- * The first argument is the host-built capability context — the canonical
71
- * `IntegrationContext` from `@ekanos/integration-schema`, the one declaration
72
- * both `@ekanos/sdk` (authoring) and this package (host) import. The
73
- * client-bearing `ToolContext` (req, admin supabase, identity fields) is
74
- * structurally absent from this signature — a partner tool cannot reach it.
75
- */
76
- export type PartnerToolRun = (integrationContext: IntegrationContext, args: Record<string, unknown>) => Promise<ToolRunResult>;
77
- export type ToolModule = {
78
- name: string;
79
- description?: string;
80
- parameters?: ToolParamsSchema;
81
- run: (ctx: ToolContext, args: Record<string, unknown>) => Promise<ToolRunResult>;
82
- /**
83
- * Partner EXECUTION function. Set by host adapter code
84
- * (`registerPartnerIntegration`'s tool adapter) alongside the host BRAND
85
- * (`brandPartnerTool`, mcp/helpers.ts) — never by first-party tool modules.
86
- *
87
- * IMPORTANT: this property is NOT the partner classification authority
88
- * (that is the module-private WeakSet brand — a property can be forged,
89
- * stripped, or varied between reads). For a host-branded tool the executor:
90
- * - invokes `partnerRun(integrationContext, args)` with the host-built
91
- * capability context and NOTHING else (no ToolContext, no prepareArgs,
92
- * no toUi);
93
- * - FAILS CLOSED if the capability context or this function is missing —
94
- * there is no legacy-context fallback for a branded tool.
95
- *
96
- * An UNBRANDED object carrying this property is treated as first-party and
97
- * can never reach the partner path — so a partner cannot escape into, and a
98
- * spoofed property cannot fake, the capability-only channel.
99
- */
100
- partnerRun?: PartnerToolRun;
101
- prepareArgs?: (ctx: ToolContext, rawArgs: unknown) => Promise<Record<string, unknown>>;
102
- ui?: UiComponentMeta | UiComponentMeta[];
103
- toUi?: (ctx: ToolContext, result: unknown) => Promise<null | RenderInstruction | RenderInstruction[]>;
104
- /**
105
- * Side-effect classification — used by the SOC 2 audit log to decide
106
- * whether the call is recorded. When omitted, the audit layer derives
107
- * it from the tool name (read-verb prefixes → 'read', otherwise 'write').
108
- * Tool authors should set this explicitly when the heuristic would be
109
- * wrong (e.g. a `generate_*` tool that materially mutates server state).
110
- * See packages/agents/src/security/tool-effect.ts.
111
- */
112
- effect?: 'read' | 'write';
113
- /**
114
- * Data classification of what this tool exposes. Mirror of
115
- * `Sensitivity` in packages/agents/src/security/redact.ts — kept inline
116
- * here to avoid a backwards dependency from integrations-core onto agents.
117
- * Reads that expose 'pii' or 'financial' data are recorded in the audit
118
- * log even though they are not writes. Defaults to undefined (treated
119
- * as 'internal' by the audit filter, 'pii' by the redaction layer).
120
- */
121
- sensitivity?: 'public' | 'internal' | 'pii' | 'financial';
122
- /**
123
- * A REPRESENTATIVE example of this tool's SUCCESS return value (top-level
124
- * shape, minimal realistic values, arrays trimmed to one element). Consumed
125
- * by the workflow authoring layer two ways:
126
- * 1. Codegen grounding — the example is embedded in the workflow-generation
127
- * prompt so the model wires `{{stepId.field}}` refs against the tool's
128
- * REAL output keys instead of guessing (`deals` vs `contacts`,
129
- * `contact_id` vs `contactId` — observed failure class).
130
- * 2. Ref linting — a workflow ref into this tool's output whose first path
131
- * segment is not a key of this example is rejected at authoring time.
132
- * Keep it SMALL (it ships in prompts), faithful to the actual run() return,
133
- * and free of real customer data. Omitting it just skips both uses.
134
- */
135
- outputExample?: Record<string, unknown>;
136
- };
137
- export type UiComponentMeta = {
138
- component: string;
139
- propsSchema: ToolParamsSchema;
140
- doc?: string;
141
- };
142
- export type RenderInstruction = {
143
- component: string;
144
- props: unknown;
145
- };
package/dist/mcp/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/mcp/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SupabaseClient } from '@supabase/supabase-js';\n\nimport type { IntegrationContext } from '@ekanos/integration-schema';\n\nexport type ToolParamsSchema = {\n type: 'object';\n properties?: Record<string, unknown>;\n required?: string[];\n additionalProperties?: boolean;\n};\n\nexport type ToolContext = {\n req: Request;\n /**\n * Admin Supabase client for in-process MCP execution.\n * This bypasses RLS; tools must perform their own authorization checks before\n * reading or mutating protected data.\n */\n supabase: SupabaseClient;\n user: { id: string } & Record<string, unknown>;\n /** The resolved account slug from the workspace context (injected by MCP route) */\n accountSlug?: string;\n /** The resolved account ID (UUID) from the workspace context (injected by MCP route) */\n accountId?: string;\n /** The resolved source ID (UUID) for the current tenant/workspace */\n sourceId?: string | null;\n /** The user's resolved IANA timezone (e.g. 'America/New_York') */\n timezone?: string;\n /** Whether the authenticated user is a platform super-admin */\n isSuperAdmin?: boolean;\n /**\n * Who is executing this tool call.\n *\n * Undefined (the default for every user-facing MCP path) is treated as\n * `'user'` — the historical behavior. `'machine'` marks a non-interactive\n * caller (the Workflow Gateway) whose identity IS the account-bound gateway\n * token, not a signed-in session. See machineGrant below and the\n * \"Machine-principal design\" section of context/N8N_INTEGRATION_PLAN.md.\n */\n principal?: 'user' | 'machine';\n /**\n * Present only when `principal === 'machine'`. Carries the account the\n * gateway token is bound to (the sole source of account identity for a\n * machine call), the token row id, and the token creator for audit\n * attribution. `getAccountId` / `ensureAccountMembership` read this instead\n * of doing a DB membership lookup — the token itself is the authorization.\n */\n machineGrant?: {\n accountId: string;\n tokenId: string;\n createdBy: string | null;\n };\n /**\n * The host-built capability context\n * (docs/devex/capability-context-proposal.md), attached ADDITIVELY by the\n * MCP route after authorization. This is the CANONICAL `IntegrationContext`\n * from `@ekanos/integration-schema` — the same declaration `@ekanos/sdk`\n * re-exports, so there is no structural twin to drift and no core→SDK\n * package cycle. Migrated tools may still narrow it with\n * `requireContext(ctx)` from `@ekanos/sdk/context`; existing tools that\n * never touch this field are unaffected.\n */\n integrationContext?: IntegrationContext;\n};\n\nexport type ToolRunResult = unknown;\n\n/**\n * The partner execution channel — the ONLY way partner-authored tool code\n * runs (capability-context proposal §3 + sdk-export-map.md adversarial\n * review outcomes 1–2).\n *\n * The first argument is the host-built capability context — the canonical\n * `IntegrationContext` from `@ekanos/integration-schema`, the one declaration\n * both `@ekanos/sdk` (authoring) and this package (host) import. The\n * client-bearing `ToolContext` (req, admin supabase, identity fields) is\n * structurally absent from this signature — a partner tool cannot reach it.\n */\nexport type PartnerToolRun = (\n integrationContext: IntegrationContext,\n args: Record<string, unknown>,\n) => Promise<ToolRunResult>;\n\nexport type ToolModule = {\n name: string;\n description?: string;\n parameters?: ToolParamsSchema;\n run: (\n ctx: ToolContext,\n args: Record<string, unknown>,\n ) => Promise<ToolRunResult>;\n\n /**\n * Partner EXECUTION function. Set by host adapter code\n * (`registerPartnerIntegration`'s tool adapter) alongside the host BRAND\n * (`brandPartnerTool`, mcp/helpers.ts) — never by first-party tool modules.\n *\n * IMPORTANT: this property is NOT the partner classification authority\n * (that is the module-private WeakSet brand — a property can be forged,\n * stripped, or varied between reads). For a host-branded tool the executor:\n * - invokes `partnerRun(integrationContext, args)` with the host-built\n * capability context and NOTHING else (no ToolContext, no prepareArgs,\n * no toUi);\n * - FAILS CLOSED if the capability context or this function is missing —\n * there is no legacy-context fallback for a branded tool.\n *\n * An UNBRANDED object carrying this property is treated as first-party and\n * can never reach the partner path — so a partner cannot escape into, and a\n * spoofed property cannot fake, the capability-only channel.\n */\n partnerRun?: PartnerToolRun;\n\n // Optional advanced features\n // Compute/override arguments from context so the model doesn't need to supply them\n prepareArgs?: (\n ctx: ToolContext,\n rawArgs: unknown,\n ) => Promise<Record<string, unknown>>;\n\n // UI rendering support: declare components and map results to render instructions\n ui?: UiComponentMeta | UiComponentMeta[];\n toUi?: (\n ctx: ToolContext,\n result: unknown,\n ) => Promise<null | RenderInstruction | RenderInstruction[]>;\n\n /**\n * Side-effect classification — used by the SOC 2 audit log to decide\n * whether the call is recorded. When omitted, the audit layer derives\n * it from the tool name (read-verb prefixes → 'read', otherwise 'write').\n * Tool authors should set this explicitly when the heuristic would be\n * wrong (e.g. a `generate_*` tool that materially mutates server state).\n * See packages/agents/src/security/tool-effect.ts.\n */\n effect?: 'read' | 'write';\n\n /**\n * Data classification of what this tool exposes. Mirror of\n * `Sensitivity` in packages/agents/src/security/redact.ts — kept inline\n * here to avoid a backwards dependency from integrations-core onto agents.\n * Reads that expose 'pii' or 'financial' data are recorded in the audit\n * log even though they are not writes. Defaults to undefined (treated\n * as 'internal' by the audit filter, 'pii' by the redaction layer).\n */\n sensitivity?: 'public' | 'internal' | 'pii' | 'financial';\n\n /**\n * A REPRESENTATIVE example of this tool's SUCCESS return value (top-level\n * shape, minimal realistic values, arrays trimmed to one element). Consumed\n * by the workflow authoring layer two ways:\n * 1. Codegen grounding — the example is embedded in the workflow-generation\n * prompt so the model wires `{{stepId.field}}` refs against the tool's\n * REAL output keys instead of guessing (`deals` vs `contacts`,\n * `contact_id` vs `contactId` — observed failure class).\n * 2. Ref linting — a workflow ref into this tool's output whose first path\n * segment is not a key of this example is rejected at authoring time.\n * Keep it SMALL (it ships in prompts), faithful to the actual run() return,\n * and free of real customer data. Omitting it just skips both uses.\n */\n outputExample?: Record<string, unknown>;\n};\n\nexport type UiComponentMeta = {\n component: string;\n propsSchema: ToolParamsSchema;\n doc?: string;\n};\n\nexport type RenderInstruction = {\n component: string;\n props: unknown;\n};\n"]}