@installagent/sdk 0.1.0 → 0.2.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.
- package/dist/agent-templates.d.ts +36 -2
- package/dist/agent-templates.js +173 -3
- package/dist/client-linear-create.d.ts +26 -0
- package/dist/client-linear-create.js +46 -0
- package/dist/client-linear.d.ts +28 -9
- package/dist/client-linear.js +36 -14
- package/dist/docs-search.d.ts +19 -6
- package/dist/docs-search.js +32 -11
- package/dist/doctor.d.ts +9 -0
- package/dist/doctor.js +126 -23
- package/dist/env-fill.d.ts +13 -0
- package/dist/env-fill.js +34 -9
- package/dist/env-push.d.ts +3 -0
- package/dist/env-push.js +11 -6
- package/dist/env-registry.d.ts +25 -0
- package/dist/env-registry.js +69 -7
- package/dist/exec.js +15 -2
- package/dist/index.d.ts +14 -6
- package/dist/index.js +14 -6
- package/dist/linear-project.d.ts +2 -2
- package/dist/linear-project.js +2 -2
- package/dist/log.d.ts +28 -0
- package/dist/log.js +73 -0
- package/dist/n8n-executions.d.ts +85 -0
- package/dist/n8n-executions.js +259 -0
- package/dist/op-cli.d.ts +29 -0
- package/dist/op-cli.js +52 -0
- package/dist/platform.d.ts +35 -0
- package/dist/platform.js +39 -0
- package/dist/portal-admin.d.ts +40 -0
- package/dist/portal-admin.js +30 -0
- package/dist/standup.d.ts +88 -0
- package/dist/standup.js +235 -0
- package/dist/sync-repos.d.ts +47 -0
- package/dist/sync-repos.js +80 -0
- package/dist/template-sync.d.ts +10 -0
- package/dist/template-sync.js +11 -0
- package/dist/wizard.d.ts +15 -0
- package/dist/wizard.js +35 -56
- package/dist/workspace-docs.d.ts +44 -0
- package/dist/workspace-docs.js +73 -0
- package/package.json +2 -2
- package/templates/env.example +33 -23
- package/templates/workspace-root/AGENT.md +7 -5
- package/templates/workspace-root/ONBOARDING.md +65 -8
- package/templates/workspace-root/skills/.github/workflows/pr-to-slack.yml +102 -0
- package/templates/workspace-root/skills/CLAUDE.md +24 -6
- package/templates/workspace-root/skills/README.md +156 -0
- package/templates/workspace-root/skills/backtest-acceptance-gates/SKILL.md +293 -0
- package/templates/workspace-root/skills/backtest-acceptance-gates/backtest-acceptance-gates-guide.pdf +0 -0
- package/templates/workspace-root/skills/backtest-acceptance-gates/references/evidence-record-template.md +128 -0
- package/templates/workspace-root/skills/backtest-acceptance-gates/references/harness-checklist.md +90 -0
- package/templates/workspace-root/skills/client-latest/SKILL.md +301 -0
- package/templates/workspace-root/skills/client-latest/catchup.command.md +17 -0
- package/templates/workspace-root/skills/cloud-devops/SKILL.md +235 -0
- package/templates/workspace-root/skills/email-triage-rollout/SKILL.md +181 -0
- package/templates/workspace-root/skills/gcloud-cli-setup/SKILL.md +100 -0
- package/templates/workspace-root/skills/google-chat-app-setup/SKILL.md +136 -0
- package/templates/workspace-root/skills/google-chat-app-setup/google-chat-app-setup-guide.pdf +0 -0
- package/templates/workspace-root/skills/house-voice/SKILL.md +80 -4
- package/templates/workspace-root/skills/ia-cli/SKILL.md +19 -6
- package/templates/workspace-root/skills/installagent-brand-kit/SKILL.md +59 -10
- package/templates/workspace-root/skills/installagent-brand-kit/assets/installagent-deck-template.pptx +0 -0
- package/templates/workspace-root/skills/installagent-brand-kit/references/deck-guide.md +181 -0
- package/templates/workspace-root/skills/installagent-brand-kit/scripts/deck.py +652 -0
- package/templates/workspace-root/skills/installagent-brand-kit/scripts/deck_lint.py +201 -0
- package/templates/workspace-root/skills/installagent-brand-kit/scripts/logo_raster.py +102 -0
- package/templates/workspace-root/skills/installagent-brand-kit/scripts/make_deck_template.py +290 -0
- package/templates/workspace-root/skills/salesforce-api-snapshot/SKILL.md +379 -0
- package/templates/workspace-root/skills/salesforce-api-snapshot/references/schema-discovery-soql.md +153 -0
- package/templates/workspace-root/skills/salesforce-api-snapshot/references/snapshot-storage.md +122 -0
- package/templates/workspace-root/skills/salesforce-api-snapshot/salesforce-api-snapshot-guide.pdf +0 -0
- package/templates/workspace-root/skills/slack-voice/SKILL.md +158 -0
- package/templates/workspace-root/skills/sso-gated-client-app/SKILL.md +337 -0
- package/templates/workspace-root/skills/sso-gated-client-app/sso-gated-client-app-guide.pdf +0 -0
- package/templates/workspace-root/skills/tech-call-prep/SKILL.md +146 -47
- package/templates/workspace-root/skills/vendor-feed-ingestion/SKILL.md +323 -0
- package/templates/workspace-root/skills/vendor-feed-ingestion/references/delivery-contract-template.md +110 -0
- package/templates/workspace-root/skills/vendor-feed-ingestion/references/feed-guards.md +134 -0
- package/templates/workspace-root/skills/vendor-feed-ingestion/vendor-feed-ingestion-guide.pdf +0 -0
package/dist/exec.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
+
import { createLogger } from "./log.js";
|
|
4
|
+
const log = createLogger("sdk.exec");
|
|
3
5
|
export const execFileAsync = async (file, args) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
// Only the binary and its subcommand are logged: later args can carry
|
|
7
|
+
// secret values (op item fields, key material) and stdout/stderr may too.
|
|
8
|
+
const shape = { file, subcommand: args[0], argCount: args.length };
|
|
9
|
+
const started = Date.now();
|
|
10
|
+
try {
|
|
11
|
+
const { stdout, stderr } = await promisify(execFile)(file, [...args]);
|
|
12
|
+
log.debug("subprocess", { ...shape, ms: Date.now() - started, ok: true });
|
|
13
|
+
return { stdout, stderr };
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
log.debug("subprocess", { ...shape, ms: Date.now() - started, ok: false });
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
6
19
|
};
|
|
7
20
|
/** Pull code/stderr off an execFile rejection without touching stdout (it may hold a secret). */
|
|
8
21
|
export function execFailureDetail(error) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
export { type AgentBankOptions, type AgentTemplateInfo, type CreateFromTemplateInput, type CreateFromTemplateResult, createFromAgentTemplate, type ListAgentTemplatesResult, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError, type SanitizedWorkflow, type SaveAgentTemplateInput, type SaveAgentTemplateOptions, type SaveAgentTemplateResult, type StrippedCredential, sanitizeN8nWorkflow, saveAgentTemplate, } from "./agent-templates.js";
|
|
1
|
+
export { type AgentBankOptions, type AgentTemplateInfo, type AgentTemplateMatch, type CreateFromTemplateInput, type CreateFromTemplateResult, createFromAgentTemplate, type ListAgentTemplatesResult, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError, type SanitizedWorkflow, type SaveAgentTemplateInput, type SaveAgentTemplateOptions, type SaveAgentTemplateResult, type SearchAgentTemplatesOptions, type SearchAgentTemplatesResult, type SopState, type StrippedCredential, sanitizeN8nWorkflow, saveAgentTemplate, searchAgentTemplates, } from "./agent-templates.js";
|
|
2
2
|
export { ClientBuildAuthError, type ClientBuildDoc, type ClientBuildOptions, type ClientBuildResult, clientBuild, GITHUB_API_TOKEN_ENV, } from "./client-build.js";
|
|
3
3
|
export { type ClientCall, type ClientContextOptions, type ClientContextResult, clientContext, } from "./client-context.js";
|
|
4
4
|
export { AIRTABLE_API_TOKEN_ENV, buildAssertionClaims, ClientDriveAuthError, type ClientDriveDoc, type ClientDriveSearchOptions, type ClientDriveSearchResult, clientDriveSearch, GOOGLE_SERVICE_ACCOUNT_KEY_ENV, parseServiceAccountKey, } from "./client-drive.js";
|
|
5
5
|
export { ClientIntakeAuthError, type ClientIntakeInput, type ClientIntakeOptions, type ClientIntakeResult, type ClientIntakeStep, clientIntake, LINEAR_CLIENT_TEAM_ID_ENV, } from "./client-intake.js";
|
|
6
|
-
export { ClientLinearAuthError, type ClientLinearProjectOptions, clientLinearProject, } from "./client-linear.js";
|
|
7
|
-
export {
|
|
6
|
+
export { ClientLinearAuthError, type ClientLinearProjectOptions, clientLinearProject, parseLinearProjectSlugId, type ResolvedClientLinearProject, resolveClientLinearProject, } from "./client-linear.js";
|
|
7
|
+
export { type ClientLinearCreateIssueInput, type ClientLinearCreateIssueResult, clientLinearCreateIssue, } from "./client-linear-create.js";
|
|
8
|
+
export { DOCS_SEARCH_TOKEN_ENV, DOCS_SESSION_ENV, type DocsSearchOptions, type DocsSearchResponse, type DocsSearchResult, DocsSessionError, docsSearch, TEAM_DOCS_BASE_URL, } from "./docs-search.js";
|
|
8
9
|
export { type DoctorCheck, type DoctorOptions, type DoctorResult, type DoctorStatus, doctor, } from "./doctor.js";
|
|
9
10
|
export { findWorkspaceRoot, type LoadWorkspaceEnvOptions, type LoadWorkspaceEnvResult, loadWorkspaceEnv, parseEnvFile, } from "./env-file.js";
|
|
10
11
|
export { type EnvFillOptions, type EnvFillResult, type EnvFillVarResult, type EnvFillVarStatus, envFill, } from "./env-fill.js";
|
|
11
12
|
export { type EnvPushOptions, type EnvPushResult, type EnvPushVarResult, type EnvPushVarStatus, envPush, } from "./env-push.js";
|
|
12
|
-
export { DEFAULT_TECH_VAULT, ENV_VARS, type EnvVarSource, type EnvVarSpec, type EnvVarTier, INFRA_VAULT, opSecretReference, renderEnvExample, } from "./env-registry.js";
|
|
13
|
+
export { ADMIN_ENV_VARS, DEFAULT_TECH_VAULT, ENV_VARS, type EnvVarRole, type EnvVarSource, type EnvVarSpec, type EnvVarTier, envVarRole, envVarsForRole, GEMINI_API_KEY_ENV, INFRA_VAULT, opSecretReference, renderEnvExample, TECH_ENV_VARS, } from "./env-registry.js";
|
|
13
14
|
export { FATHOM_API_BASE_URL, FATHOM_API_KEY_ENV, FATHOM_INCLUDES, FATHOM_TRIGGERS, type MintFathomWebhookOptions, type MintFathomWebhookResult, mintFathomWebhook, } from "./fathom-webhook.js";
|
|
14
15
|
export { type ExecFileFn, MINT_HANDOFF_WARNING, type MintGcpServiceAccountKeyOptions, type MintGcpServiceAccountKeyResult, mintGcpServiceAccountKey, } from "./gcp-service-account-key.js";
|
|
15
16
|
export { DEFAULT_GEMINI_KEY_DISPLAY_NAME, GEMINI_API_TARGET, type MintGeminiApiKeyOptions, type MintGeminiApiKeyResult, mintGeminiApiKey, } from "./gemini-api-key.js";
|
|
@@ -17,9 +18,16 @@ export { type CloneFn, type CloneOptions, gitClone, gitPullFfOnly, type PullFn }
|
|
|
17
18
|
export { GITHUB_TOKEN_FIX, type ResolvedGithubToken, type ResolveGithubTokenOptions, resolveGithubToken, } from "./github-token.js";
|
|
18
19
|
export { CLIENT_TEMPLATE_URL, type InitStep, type InitWorkspaceOptions, type InitWorkspaceResult, initWorkspace, MCP_RECOMMENDATIONS, type McpRecommendation, TEAM_CLIENTS_URL, } from "./init.js";
|
|
19
20
|
export { findProjectBySlugId, LINEAR_API_TOKEN_ENV, LinearAuthError, type LinearIssue, LinearProjectNotFoundError, type LinearProjectOptions, type LinearProjectResult, linearProject, linearProjectIssues, type ProjectNode, } from "./linear-project.js";
|
|
21
|
+
export { type CreateLoggerOptions, createLogger, type LogFields, type Logger, type LogLevel, redactFields, } from "./log.js";
|
|
22
|
+
export { type ExtractNodeOutputsOptions, extractNodeOutputs, listN8nExecutions, listNodesRun, type N8nExecutionDetail, type N8nExecutionStatus, type N8nExecutionSummary, type N8nExecutionsInput, type N8nExecutionsOptions, type N8nExecutionsResult, type N8nNodeOutput, unflattenExecutionData, } from "./n8n-executions.js";
|
|
20
23
|
export { type NewClientOptions, type NewClientResult, newClient, SLUG_PATTERN, } from "./new-client.js";
|
|
24
|
+
export { opInstallCommand, opInstallFix, opIntegrationFix } from "./op-cli.js";
|
|
21
25
|
export { type PingResult, ping } from "./ping.js";
|
|
22
|
-
export {
|
|
26
|
+
export { detectPlatform, detectPlatformInfo, detectShell, opNeedsAnotherShell, type Platform, type PlatformInfo, type Shell, } from "./platform.js";
|
|
27
|
+
export { DEFAULT_PORTAL_URL, PORTAL_ADMIN_SECRET_ENV, PORTAL_PASSWORD_WARNING, PORTAL_SYNC_MAX_DAYS, PORTAL_URL_ENV, type PortalAddUserInput, type PortalAddUserResult, PortalAdminAuthError, type PortalAdminOptions, type PortalAgent, type PortalAgentSyncRow, type PortalCreateAgentInput, type PortalCreateOrgInput, type PortalCreateOrgResult, type PortalListAgentsResult, type PortalListOrgsResult, type PortalOrg, type PortalOrgUser, type PortalSetAgentNameInput, type PortalSetAgentNameResult, type PortalSetAgentStatusInput, type PortalSetAgentStatusResult, type PortalSetAgentWorkflowInput, type PortalSetAgentWorkflowResult, type PortalSetDriveFolderResult, type PortalSetPasswordResult, type PortalSyncRunsResult, portalAddUser, portalCreateAgent, portalCreateOrg, portalListAgents, portalListOrgs, portalSetAgentName, portalSetAgentStatus, portalSetAgentWorkflow, portalSetDriveFolder, portalSetPassword, portalSyncRuns, } from "./portal-admin.js";
|
|
28
|
+
export { type StandupCallPrep, type StandupCallPrepStatus, type StandupGitState, type StandupIssueRef, type StandupLinear, type StandupOptions, type StandupRepo, type StandupRepoLint, type StandupResult, type StandupStaleTodo, standup, } from "./standup.js";
|
|
29
|
+
export { type SyncRepoResult, type SyncRepoStatus, type SyncReposOptions, type SyncReposResult, syncRepos, } from "./sync-repos.js";
|
|
23
30
|
export { type SyncTemplatesFileResult, type SyncTemplatesFileStatus, type SyncTemplatesOptions, type SyncTemplatesResult, syncTemplates, TEMPLATE_CLAUDE_SETTINGS, TEMPLATE_ROOT_DOCS, } from "./sync-templates.js";
|
|
24
31
|
export { TEMPLATE_SYNCED_FILES, type TemplateSyncFileResult, type TemplateSyncFileStatus, type TemplateSyncOptions, type TemplateSyncRepoResult, type TemplateSyncResult, templateSync, } from "./template-sync.js";
|
|
25
|
-
export { WIZARD_REPO_NAMES, type WizardStep, type WizardWorkspaceOptions, type WizardWorkspaceResult, wizardWorkspace, } from "./wizard.js";
|
|
32
|
+
export { type CloneProtocol, repoUrl, WIZARD_REPO_NAMES, type WizardStep, type WizardWorkspaceOptions, type WizardWorkspaceResult, wizardWorkspace, } from "./wizard.js";
|
|
33
|
+
export { type EnvExampleStatus, refreshEnvExample, refreshWorkspaceDocs, resolveTemplateDir, type WorkspaceDocsResult, } from "./workspace-docs.js";
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// @installagent/sdk — the only place with real logic. apps/cli and
|
|
2
2
|
// apps/mcp are thin adapters over these exports; every operation here must be
|
|
3
3
|
// reachable from both. See ../../docs/spec.md.
|
|
4
|
-
export { createFromAgentTemplate, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError, sanitizeN8nWorkflow, saveAgentTemplate, } from "./agent-templates.js";
|
|
4
|
+
export { createFromAgentTemplate, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError, sanitizeN8nWorkflow, saveAgentTemplate, searchAgentTemplates, } from "./agent-templates.js";
|
|
5
5
|
export { ClientBuildAuthError, clientBuild, GITHUB_API_TOKEN_ENV, } from "./client-build.js";
|
|
6
6
|
export { clientContext, } from "./client-context.js";
|
|
7
7
|
export { AIRTABLE_API_TOKEN_ENV, buildAssertionClaims, ClientDriveAuthError, clientDriveSearch, GOOGLE_SERVICE_ACCOUNT_KEY_ENV, parseServiceAccountKey, } from "./client-drive.js";
|
|
8
8
|
export { ClientIntakeAuthError, clientIntake, LINEAR_CLIENT_TEAM_ID_ENV, } from "./client-intake.js";
|
|
9
|
-
export { ClientLinearAuthError, clientLinearProject, } from "./client-linear.js";
|
|
10
|
-
export {
|
|
9
|
+
export { ClientLinearAuthError, clientLinearProject, parseLinearProjectSlugId, resolveClientLinearProject, } from "./client-linear.js";
|
|
10
|
+
export { clientLinearCreateIssue, } from "./client-linear-create.js";
|
|
11
|
+
export { DOCS_SEARCH_TOKEN_ENV, DOCS_SESSION_ENV, DocsSessionError, docsSearch, TEAM_DOCS_BASE_URL, } from "./docs-search.js";
|
|
11
12
|
export { doctor, } from "./doctor.js";
|
|
12
13
|
export { findWorkspaceRoot, loadWorkspaceEnv, parseEnvFile, } from "./env-file.js";
|
|
13
14
|
export { envFill, } from "./env-fill.js";
|
|
14
15
|
export { envPush, } from "./env-push.js";
|
|
15
|
-
export { DEFAULT_TECH_VAULT, ENV_VARS, INFRA_VAULT, opSecretReference, renderEnvExample, } from "./env-registry.js";
|
|
16
|
+
export { ADMIN_ENV_VARS, DEFAULT_TECH_VAULT, ENV_VARS, envVarRole, envVarsForRole, GEMINI_API_KEY_ENV, INFRA_VAULT, opSecretReference, renderEnvExample, TECH_ENV_VARS, } from "./env-registry.js";
|
|
16
17
|
export { FATHOM_API_BASE_URL, FATHOM_API_KEY_ENV, FATHOM_INCLUDES, FATHOM_TRIGGERS, mintFathomWebhook, } from "./fathom-webhook.js";
|
|
17
18
|
export { MINT_HANDOFF_WARNING, mintGcpServiceAccountKey, } from "./gcp-service-account-key.js";
|
|
18
19
|
export { DEFAULT_GEMINI_KEY_DISPLAY_NAME, GEMINI_API_TARGET, mintGeminiApiKey, } from "./gemini-api-key.js";
|
|
@@ -20,9 +21,16 @@ export { gitClone, gitPullFfOnly } from "./git.js";
|
|
|
20
21
|
export { GITHUB_TOKEN_FIX, resolveGithubToken, } from "./github-token.js";
|
|
21
22
|
export { CLIENT_TEMPLATE_URL, initWorkspace, MCP_RECOMMENDATIONS, TEAM_CLIENTS_URL, } from "./init.js";
|
|
22
23
|
export { findProjectBySlugId, LINEAR_API_TOKEN_ENV, LinearAuthError, LinearProjectNotFoundError, linearProject, linearProjectIssues, } from "./linear-project.js";
|
|
24
|
+
export { createLogger, redactFields, } from "./log.js";
|
|
25
|
+
export { extractNodeOutputs, listN8nExecutions, listNodesRun, unflattenExecutionData, } from "./n8n-executions.js";
|
|
23
26
|
export { newClient, SLUG_PATTERN, } from "./new-client.js";
|
|
27
|
+
export { opInstallCommand, opInstallFix, opIntegrationFix } from "./op-cli.js";
|
|
24
28
|
export { ping } from "./ping.js";
|
|
25
|
-
export {
|
|
29
|
+
export { detectPlatform, detectPlatformInfo, detectShell, opNeedsAnotherShell, } from "./platform.js";
|
|
30
|
+
export { DEFAULT_PORTAL_URL, PORTAL_ADMIN_SECRET_ENV, PORTAL_PASSWORD_WARNING, PORTAL_SYNC_MAX_DAYS, PORTAL_URL_ENV, PortalAdminAuthError, portalAddUser, portalCreateAgent, portalCreateOrg, portalListAgents, portalListOrgs, portalSetAgentName, portalSetAgentStatus, portalSetAgentWorkflow, portalSetDriveFolder, portalSetPassword, portalSyncRuns, } from "./portal-admin.js";
|
|
31
|
+
export { standup, } from "./standup.js";
|
|
32
|
+
export { syncRepos, } from "./sync-repos.js";
|
|
26
33
|
export { syncTemplates, TEMPLATE_CLAUDE_SETTINGS, TEMPLATE_ROOT_DOCS, } from "./sync-templates.js";
|
|
27
34
|
export { TEMPLATE_SYNCED_FILES, templateSync, } from "./template-sync.js";
|
|
28
|
-
export { WIZARD_REPO_NAMES, wizardWorkspace, } from "./wizard.js";
|
|
35
|
+
export { repoUrl, WIZARD_REPO_NAMES, wizardWorkspace, } from "./wizard.js";
|
|
36
|
+
export { refreshEnvExample, refreshWorkspaceDocs, resolveTemplateDir, } from "./workspace-docs.js";
|
package/dist/linear-project.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare function findProjectBySlugId(fetchImpl: typeof fetch, token: stri
|
|
|
60
60
|
* title + description (with `query`), same scoring shape as clientBuild and
|
|
61
61
|
* docsSearch. `label` narrows to issues carrying that label first, before
|
|
62
62
|
* query scoring or the index sort — useful for a project that tracks more
|
|
63
|
-
* than one initiative's backlog (e.g. Install Agent's internal "
|
|
63
|
+
* than one initiative's backlog (e.g. Install Agent's internal "install-agent"
|
|
64
64
|
* project) or, for a client project, just as an extra filter.
|
|
65
65
|
*
|
|
66
66
|
* Strictly read-only: only ever sends GraphQL queries, never mutations.
|
|
@@ -72,7 +72,7 @@ export declare function linearProjectIssues(fetchImpl: typeof fetch, token: stri
|
|
|
72
72
|
* Open issues in a Linear project, resolved by display name (exact match,
|
|
73
73
|
* then a case-insensitive fuzzy fallback that refuses with the candidate
|
|
74
74
|
* list if ambiguous). For Install Agent's internal backlog — e.g. the
|
|
75
|
-
* "
|
|
75
|
+
* "install-agent" project — where there's no per-client record to resolve a
|
|
76
76
|
* stable ID from. For a client engagement's Linear project, use
|
|
77
77
|
* `clientLinearProject` instead: it resolves by the client's own
|
|
78
78
|
* `CLIENT.md` record rather than a guessed or typed name, and applies the
|
package/dist/linear-project.js
CHANGED
|
@@ -120,7 +120,7 @@ function countOccurrences(text, term) {
|
|
|
120
120
|
* title + description (with `query`), same scoring shape as clientBuild and
|
|
121
121
|
* docsSearch. `label` narrows to issues carrying that label first, before
|
|
122
122
|
* query scoring or the index sort — useful for a project that tracks more
|
|
123
|
-
* than one initiative's backlog (e.g. Install Agent's internal "
|
|
123
|
+
* than one initiative's backlog (e.g. Install Agent's internal "install-agent"
|
|
124
124
|
* project) or, for a client project, just as an extra filter.
|
|
125
125
|
*
|
|
126
126
|
* Strictly read-only: only ever sends GraphQL queries, never mutations.
|
|
@@ -171,7 +171,7 @@ export async function linearProjectIssues(fetchImpl, token, project, options = {
|
|
|
171
171
|
* Open issues in a Linear project, resolved by display name (exact match,
|
|
172
172
|
* then a case-insensitive fuzzy fallback that refuses with the candidate
|
|
173
173
|
* list if ambiguous). For Install Agent's internal backlog — e.g. the
|
|
174
|
-
* "
|
|
174
|
+
* "install-agent" project — where there's no per-client record to resolve a
|
|
175
175
|
* stable ID from. For a client engagement's Linear project, use
|
|
176
176
|
* `clientLinearProject` instead: it resolves by the client's own
|
|
177
177
|
* `CLIENT.md` record rather than a guessed or typed name, and applies the
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type LogLevel = "debug" | "info" | "warn" | "error" | "silent";
|
|
2
|
+
export type LogFields = Record<string, unknown>;
|
|
3
|
+
export interface Logger {
|
|
4
|
+
debug(event: string, fields?: LogFields): void;
|
|
5
|
+
info(event: string, fields?: LogFields): void;
|
|
6
|
+
warn(event: string, fields?: LogFields): void;
|
|
7
|
+
error(event: string, fields?: LogFields): void;
|
|
8
|
+
/** A logger that stamps these fields onto every line it writes. */
|
|
9
|
+
child(fields: LogFields): Logger;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateLoggerOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Level floor used when IA_LOG_LEVEL is unset. Defaults to "silent" so the
|
|
14
|
+
* CLI's human output stays clean unless the technician asks for logs; the
|
|
15
|
+
* long-running MCP HTTP server passes "info" so it always has an audit
|
|
16
|
+
* trail.
|
|
17
|
+
*/
|
|
18
|
+
defaultLevel?: LogLevel;
|
|
19
|
+
/** Line sink override for tests. Default: process.stderr. */
|
|
20
|
+
write?: (line: string) => void;
|
|
21
|
+
/** Env override for tests. Default: process.env. */
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
/** Clock override for tests. Default: () => new Date(). */
|
|
24
|
+
now?: () => Date;
|
|
25
|
+
}
|
|
26
|
+
/** Replace any secret-shaped field's value; recurse one level into plain objects. */
|
|
27
|
+
export declare function redactFields(fields: LogFields): LogFields;
|
|
28
|
+
export declare function createLogger(component: string, options?: CreateLoggerOptions): Logger;
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Structured logging for the SDK and its adapters (CLI --verbose, the MCP
|
|
2
|
+
// server's audit trail). One JSON object per line, written to stderr — stdout
|
|
3
|
+
// stays reserved for command output (minted secrets, --json payloads).
|
|
4
|
+
//
|
|
5
|
+
// The level is resolved from IA_LOG_LEVEL on every call, not captured at
|
|
6
|
+
// creation: the CLI's --verbose flag sets the env var in a preAction hook,
|
|
7
|
+
// after loggers may already exist.
|
|
8
|
+
//
|
|
9
|
+
// Field values whose KEY looks secret-shaped are redacted before serializing.
|
|
10
|
+
// This is a backstop, not permission to log secrets — never pass one in.
|
|
11
|
+
const LEVEL_RANK = {
|
|
12
|
+
debug: 10,
|
|
13
|
+
info: 20,
|
|
14
|
+
warn: 30,
|
|
15
|
+
error: 40,
|
|
16
|
+
silent: 99,
|
|
17
|
+
};
|
|
18
|
+
const SECRET_KEY = /token|secret|key|password|cookie|session|credential|authorization/i;
|
|
19
|
+
function isLogLevel(value) {
|
|
20
|
+
return value === "debug" || value === "info" || value === "warn" || value === "error";
|
|
21
|
+
}
|
|
22
|
+
/** Replace any secret-shaped field's value; recurse one level into plain objects. */
|
|
23
|
+
export function redactFields(fields) {
|
|
24
|
+
const out = {};
|
|
25
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
26
|
+
if (SECRET_KEY.test(key)) {
|
|
27
|
+
out[key] = "[redacted]";
|
|
28
|
+
}
|
|
29
|
+
else if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
30
|
+
out[key] = redactFields(value);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
out[key] = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
export function createLogger(component, options = {}) {
|
|
39
|
+
const env = options.env ?? process.env;
|
|
40
|
+
const write = options.write ?? ((line) => process.stderr.write(`${line}\n`));
|
|
41
|
+
const now = options.now ?? (() => new Date());
|
|
42
|
+
const defaultLevel = options.defaultLevel ?? "silent";
|
|
43
|
+
function threshold() {
|
|
44
|
+
const configured = env.IA_LOG_LEVEL?.toLowerCase();
|
|
45
|
+
if (configured === "silent")
|
|
46
|
+
return LEVEL_RANK.silent;
|
|
47
|
+
if (isLogLevel(configured))
|
|
48
|
+
return LEVEL_RANK[configured];
|
|
49
|
+
return LEVEL_RANK[defaultLevel];
|
|
50
|
+
}
|
|
51
|
+
function make(bound) {
|
|
52
|
+
function emit(level, event, fields) {
|
|
53
|
+
if (LEVEL_RANK[level] < threshold())
|
|
54
|
+
return;
|
|
55
|
+
const line = {
|
|
56
|
+
ts: now().toISOString(),
|
|
57
|
+
level,
|
|
58
|
+
component,
|
|
59
|
+
event,
|
|
60
|
+
...redactFields({ ...bound, ...(fields ?? {}) }),
|
|
61
|
+
};
|
|
62
|
+
write(JSON.stringify(line));
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
debug: (event, fields) => emit("debug", event, fields),
|
|
66
|
+
info: (event, fields) => emit("info", event, fields),
|
|
67
|
+
warn: (event, fields) => emit("warn", event, fields),
|
|
68
|
+
error: (event, fields) => emit("error", event, fields),
|
|
69
|
+
child: (fields) => make({ ...bound, ...fields }),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return make({});
|
|
73
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError } from "./agent-templates.js";
|
|
2
|
+
export { N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError };
|
|
3
|
+
export type N8nExecutionStatus = "canceled" | "crashed" | "error" | "new" | "running" | "success" | "unknown" | "waiting";
|
|
4
|
+
export interface N8nExecutionSummary {
|
|
5
|
+
id: string;
|
|
6
|
+
workflowId: string;
|
|
7
|
+
status: string;
|
|
8
|
+
mode: string;
|
|
9
|
+
startedAt: string | null;
|
|
10
|
+
stoppedAt: string | null;
|
|
11
|
+
/** Wall-clock milliseconds, when both timestamps are present. */
|
|
12
|
+
durationMs: number | null;
|
|
13
|
+
}
|
|
14
|
+
export interface N8nNodeOutput {
|
|
15
|
+
executionId: string;
|
|
16
|
+
startedAt: string | null;
|
|
17
|
+
node: string;
|
|
18
|
+
/** 0-based index of the node's run within the execution (loops run > once). */
|
|
19
|
+
runIndex: number;
|
|
20
|
+
/** 0-based output branch — IF/Switch nodes emit on more than one. */
|
|
21
|
+
branch: number;
|
|
22
|
+
json: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export interface N8nExecutionDetail extends N8nExecutionSummary {
|
|
25
|
+
/** Decoded run data, present only when the caller opted into it. */
|
|
26
|
+
nodeOutputs?: N8nNodeOutput[];
|
|
27
|
+
/** Node names that ran, in execution order — always cheap, never PHI. */
|
|
28
|
+
nodesRun?: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Decode n8n's `flatted` execution payload back into a plain object.
|
|
32
|
+
*
|
|
33
|
+
* In `flatted`, every value is hoisted into one array and referenced by its
|
|
34
|
+
* stringified index — including strings themselves, so `"12"` means "entry 12"
|
|
35
|
+
* and never the literal text. Cycles are legal in the format, so resolved
|
|
36
|
+
* entries are memoized and a node already being resolved yields `null` rather
|
|
37
|
+
* than recursing forever.
|
|
38
|
+
*/
|
|
39
|
+
export declare function unflattenExecutionData(payload: string): unknown;
|
|
40
|
+
export interface ExtractNodeOutputsOptions {
|
|
41
|
+
/** Restrict to one node by exact name. Omit for every node that ran. */
|
|
42
|
+
node?: string;
|
|
43
|
+
/** Project each item down to these JSON keys — the PHI-safe path. */
|
|
44
|
+
fields?: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pull per-item node outputs out of decoded execution data.
|
|
48
|
+
* Shape: resultData.runData[nodeName][runIndex].data.main[branch][item].json
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractNodeOutputs(decoded: unknown, executionId: string, startedAt: string | null, opts?: ExtractNodeOutputsOptions): N8nNodeOutput[];
|
|
51
|
+
export declare function listNodesRun(decoded: unknown): string[];
|
|
52
|
+
export interface N8nExecutionsInput {
|
|
53
|
+
workflowId?: string;
|
|
54
|
+
/** How many executions to return. The API pages at 100; this walks pages. */
|
|
55
|
+
limit?: number;
|
|
56
|
+
status?: N8nExecutionStatus;
|
|
57
|
+
/**
|
|
58
|
+
* Fetch and decode each execution's run data. Off by default: run data
|
|
59
|
+
* carries full client payloads. Pair with `fields` to stay PHI-safe.
|
|
60
|
+
*/
|
|
61
|
+
includeData?: boolean;
|
|
62
|
+
node?: string;
|
|
63
|
+
fields?: string[];
|
|
64
|
+
}
|
|
65
|
+
export interface N8nExecutionsOptions {
|
|
66
|
+
/** n8n API base incl. /api/v1; defaults to $N8N_API_URL. */
|
|
67
|
+
baseUrl?: string;
|
|
68
|
+
/** Defaults to $N8N_API_KEY. */
|
|
69
|
+
apiKey?: string;
|
|
70
|
+
/** Injectable for tests; defaults to global fetch. */
|
|
71
|
+
fetchImpl?: typeof fetch;
|
|
72
|
+
env?: Record<string, string | undefined>;
|
|
73
|
+
}
|
|
74
|
+
export interface N8nExecutionsResult {
|
|
75
|
+
executions: N8nExecutionDetail[];
|
|
76
|
+
/** True when more executions exist past `limit`. */
|
|
77
|
+
hasMore: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* List executions for a workflow, newest first, optionally decoding run data.
|
|
81
|
+
*
|
|
82
|
+
* Without `includeData` this is one cheap paged call. With it, each execution
|
|
83
|
+
* costs an extra GET, so keep `limit` bounded when sweeping history.
|
|
84
|
+
*/
|
|
85
|
+
export declare function listN8nExecutions(input?: N8nExecutionsInput, opts?: N8nExecutionsOptions): Promise<N8nExecutionsResult>;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// Read n8n execution history over the public REST API. The reason this module
|
|
2
|
+
// exists: n8n stores each execution's node-by-node run data in the `flatted`
|
|
3
|
+
// wire format (a flat array where every string of digits is an index back into
|
|
4
|
+
// that same array), so a raw API response is unreadable without a decoder.
|
|
5
|
+
// `unflattenExecutionData` is that decoder.
|
|
6
|
+
//
|
|
7
|
+
// PHI posture: execution run data contains whole emails, records, and client
|
|
8
|
+
// payloads. Metadata is returned by default; run data requires an explicit
|
|
9
|
+
// opt-in, and `fields` projects each node's output down to named keys so an
|
|
10
|
+
// analysis can pull `disposition`/`confidence` without ever materializing a
|
|
11
|
+
// message body. Client repos staging this output must keep it in gitignored
|
|
12
|
+
// data/ — see clients/client-template/AGENT.md.
|
|
13
|
+
import { N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError } from "./agent-templates.js";
|
|
14
|
+
export { N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError };
|
|
15
|
+
const DIGITS = /^\d+$/;
|
|
16
|
+
const MAX_DEPTH = 200;
|
|
17
|
+
/**
|
|
18
|
+
* Decode n8n's `flatted` execution payload back into a plain object.
|
|
19
|
+
*
|
|
20
|
+
* In `flatted`, every value is hoisted into one array and referenced by its
|
|
21
|
+
* stringified index — including strings themselves, so `"12"` means "entry 12"
|
|
22
|
+
* and never the literal text. Cycles are legal in the format, so resolved
|
|
23
|
+
* entries are memoized and a node already being resolved yields `null` rather
|
|
24
|
+
* than recursing forever.
|
|
25
|
+
*/
|
|
26
|
+
export function unflattenExecutionData(payload) {
|
|
27
|
+
let arr;
|
|
28
|
+
try {
|
|
29
|
+
const parsed = JSON.parse(payload);
|
|
30
|
+
if (!Array.isArray(parsed))
|
|
31
|
+
return parsed;
|
|
32
|
+
arr = parsed;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (arr.length === 0)
|
|
38
|
+
return null;
|
|
39
|
+
const resolved = new Map();
|
|
40
|
+
// Dereference one slot. Whatever sits at arr[index] is that value LITERALLY —
|
|
41
|
+
// a string there is real text, never another index. Only values *inside*
|
|
42
|
+
// containers are indices, which is what keeps digit-only strings in client
|
|
43
|
+
// data (an id, a ZIP, "2") from being chased as pointers.
|
|
44
|
+
const deref = (index, depth) => {
|
|
45
|
+
if (resolved.has(index))
|
|
46
|
+
return resolved.get(index);
|
|
47
|
+
const entry = arr[index];
|
|
48
|
+
if (!entry || typeof entry !== "object") {
|
|
49
|
+
resolved.set(index, entry);
|
|
50
|
+
return entry;
|
|
51
|
+
}
|
|
52
|
+
if (depth > MAX_DEPTH)
|
|
53
|
+
return null;
|
|
54
|
+
// Register the container before walking into it so a cycle resolves to the
|
|
55
|
+
// same instance instead of recursing forever.
|
|
56
|
+
const out = Array.isArray(entry) ? [] : {};
|
|
57
|
+
resolved.set(index, out);
|
|
58
|
+
if (Array.isArray(entry)) {
|
|
59
|
+
for (const item of entry)
|
|
60
|
+
out.push(revive(item, depth + 1));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
64
|
+
out[key] = revive(value, depth + 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
};
|
|
69
|
+
// A value held inside a container: in this format that is always an index.
|
|
70
|
+
const revive = (value, depth) => {
|
|
71
|
+
if (typeof value === "string" && DIGITS.test(value)) {
|
|
72
|
+
const index = Number(value);
|
|
73
|
+
if (Number.isInteger(index) && index >= 0 && index < arr.length)
|
|
74
|
+
return deref(index, depth);
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
};
|
|
78
|
+
return deref(0, 0);
|
|
79
|
+
}
|
|
80
|
+
function isRecord(value) {
|
|
81
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
82
|
+
}
|
|
83
|
+
/** Keep only `fields` from each output item. Undeclared keys never leave the process. */
|
|
84
|
+
function projectFields(json, fields) {
|
|
85
|
+
if (!fields || fields.length === 0)
|
|
86
|
+
return json;
|
|
87
|
+
const out = {};
|
|
88
|
+
for (const field of fields) {
|
|
89
|
+
if (field in json)
|
|
90
|
+
out[field] = json[field];
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Pull per-item node outputs out of decoded execution data.
|
|
96
|
+
* Shape: resultData.runData[nodeName][runIndex].data.main[branch][item].json
|
|
97
|
+
*/
|
|
98
|
+
export function extractNodeOutputs(decoded, executionId, startedAt, opts = {}) {
|
|
99
|
+
const outputs = [];
|
|
100
|
+
if (!isRecord(decoded))
|
|
101
|
+
return outputs;
|
|
102
|
+
const resultData = decoded.resultData;
|
|
103
|
+
if (!isRecord(resultData))
|
|
104
|
+
return outputs;
|
|
105
|
+
const runData = resultData.runData;
|
|
106
|
+
if (!isRecord(runData))
|
|
107
|
+
return outputs;
|
|
108
|
+
for (const [node, runs] of Object.entries(runData)) {
|
|
109
|
+
if (opts.node && node !== opts.node)
|
|
110
|
+
continue;
|
|
111
|
+
if (!Array.isArray(runs))
|
|
112
|
+
continue;
|
|
113
|
+
runs.forEach((run, runIndex) => {
|
|
114
|
+
if (!isRecord(run))
|
|
115
|
+
return;
|
|
116
|
+
const data = run.data;
|
|
117
|
+
if (!isRecord(data))
|
|
118
|
+
return;
|
|
119
|
+
const main = data.main;
|
|
120
|
+
if (!Array.isArray(main))
|
|
121
|
+
return;
|
|
122
|
+
main.forEach((branchItems, branch) => {
|
|
123
|
+
if (!Array.isArray(branchItems))
|
|
124
|
+
return;
|
|
125
|
+
for (const item of branchItems) {
|
|
126
|
+
if (!isRecord(item) || !isRecord(item.json))
|
|
127
|
+
continue;
|
|
128
|
+
outputs.push({
|
|
129
|
+
executionId,
|
|
130
|
+
startedAt,
|
|
131
|
+
node,
|
|
132
|
+
runIndex,
|
|
133
|
+
branch,
|
|
134
|
+
json: projectFields(item.json, opts.fields),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return outputs;
|
|
141
|
+
}
|
|
142
|
+
export function listNodesRun(decoded) {
|
|
143
|
+
if (!isRecord(decoded))
|
|
144
|
+
return [];
|
|
145
|
+
const resultData = decoded.resultData;
|
|
146
|
+
if (!isRecord(resultData))
|
|
147
|
+
return [];
|
|
148
|
+
const runData = resultData.runData;
|
|
149
|
+
if (!isRecord(runData))
|
|
150
|
+
return [];
|
|
151
|
+
return Object.keys(runData);
|
|
152
|
+
}
|
|
153
|
+
const PAGE_SIZE = 100;
|
|
154
|
+
function resolveAuth(opts) {
|
|
155
|
+
const env = opts.env ?? process.env;
|
|
156
|
+
const baseUrl = (opts.baseUrl ?? env[N8N_API_URL_ENV])?.replace(/\/+$/, "");
|
|
157
|
+
const apiKey = opts.apiKey ?? env[N8N_API_KEY_ENV];
|
|
158
|
+
if (!baseUrl || !apiKey) {
|
|
159
|
+
throw new N8nAuthError(`n8n API not configured — set $${N8N_API_URL_ENV} (incl. /api/v1) and $${N8N_API_KEY_ENV} (1Password).`);
|
|
160
|
+
}
|
|
161
|
+
return { baseUrl, apiKey };
|
|
162
|
+
}
|
|
163
|
+
function toSummary(raw) {
|
|
164
|
+
const startedAt = raw.startedAt ? String(raw.startedAt) : null;
|
|
165
|
+
const stoppedAt = raw.stoppedAt ? String(raw.stoppedAt) : null;
|
|
166
|
+
let durationMs = null;
|
|
167
|
+
if (startedAt && stoppedAt) {
|
|
168
|
+
const delta = Date.parse(stoppedAt) - Date.parse(startedAt);
|
|
169
|
+
durationMs = Number.isFinite(delta) ? delta : null;
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
id: String(raw.id ?? ""),
|
|
173
|
+
workflowId: String(raw.workflowId ?? ""),
|
|
174
|
+
status: String(raw.status ?? "unknown"),
|
|
175
|
+
mode: String(raw.mode ?? ""),
|
|
176
|
+
startedAt,
|
|
177
|
+
stoppedAt,
|
|
178
|
+
durationMs,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* List executions for a workflow, newest first, optionally decoding run data.
|
|
183
|
+
*
|
|
184
|
+
* Without `includeData` this is one cheap paged call. With it, each execution
|
|
185
|
+
* costs an extra GET, so keep `limit` bounded when sweeping history.
|
|
186
|
+
*/
|
|
187
|
+
export async function listN8nExecutions(input = {}, opts = {}) {
|
|
188
|
+
const { baseUrl, apiKey } = resolveAuth(opts);
|
|
189
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
190
|
+
const headers = { "X-N8N-API-KEY": apiKey, accept: "application/json" };
|
|
191
|
+
const limit = Math.max(1, input.limit ?? 20);
|
|
192
|
+
const summaries = [];
|
|
193
|
+
let cursor;
|
|
194
|
+
let hasMore = false;
|
|
195
|
+
while (summaries.length < limit) {
|
|
196
|
+
const params = new URLSearchParams({
|
|
197
|
+
limit: String(Math.min(PAGE_SIZE, limit - summaries.length)),
|
|
198
|
+
});
|
|
199
|
+
if (input.workflowId)
|
|
200
|
+
params.set("workflowId", input.workflowId);
|
|
201
|
+
if (input.status)
|
|
202
|
+
params.set("status", input.status);
|
|
203
|
+
if (cursor)
|
|
204
|
+
params.set("cursor", cursor);
|
|
205
|
+
const response = await fetchImpl(`${baseUrl}/executions?${params}`, { headers });
|
|
206
|
+
// 401 and 403 mean different things here and the fix differs. n8n API keys
|
|
207
|
+
// carry per-resource scopes, so a key that reads /workflows fine (and so
|
|
208
|
+
// passes `ia doctor`) still 403s on /executions when execution:read was not
|
|
209
|
+
// granted. Saying "rejected your key" would send someone off rotating a
|
|
210
|
+
// perfectly good credential.
|
|
211
|
+
if (response.status === 401) {
|
|
212
|
+
throw new N8nAuthError(`n8n rejected $${N8N_API_KEY_ENV} (HTTP 401) — the key is invalid or expired.`);
|
|
213
|
+
}
|
|
214
|
+
if (response.status === 403) {
|
|
215
|
+
throw new N8nAuthError(`n8n accepted $${N8N_API_KEY_ENV} but refused /executions (HTTP 403). The key is missing the "execution:read" scope — regenerate it in n8n under Settings > n8n API with that scope ticked, then update the value in 1Password and the workspace .env.`);
|
|
216
|
+
}
|
|
217
|
+
if (!response.ok)
|
|
218
|
+
throw new Error(`n8n API ${response.status} listing executions`);
|
|
219
|
+
const body = (await response.json());
|
|
220
|
+
const page = Array.isArray(body.data) ? body.data : [];
|
|
221
|
+
for (const raw of page) {
|
|
222
|
+
if (isRecord(raw))
|
|
223
|
+
summaries.push(toSummary(raw));
|
|
224
|
+
}
|
|
225
|
+
cursor = body.nextCursor ? String(body.nextCursor) : undefined;
|
|
226
|
+
if (!cursor || page.length === 0)
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
if (summaries.length > limit)
|
|
230
|
+
summaries.length = limit;
|
|
231
|
+
if (cursor)
|
|
232
|
+
hasMore = true;
|
|
233
|
+
if (!input.includeData)
|
|
234
|
+
return { executions: summaries, hasMore };
|
|
235
|
+
const executions = [];
|
|
236
|
+
for (const summary of summaries) {
|
|
237
|
+
const response = await fetchImpl(`${baseUrl}/executions/${encodeURIComponent(summary.id)}?includeData=true`, { headers });
|
|
238
|
+
// Never let a permission failure look like "this execution had no data" —
|
|
239
|
+
// silently empty run data reads as a finding, and it isn't one.
|
|
240
|
+
if (response.status === 401 || response.status === 403) {
|
|
241
|
+
throw new N8nAuthError(`n8n refused run data for execution ${summary.id} (HTTP ${response.status}) — $${N8N_API_KEY_ENV} needs the "execution:read" scope.`);
|
|
242
|
+
}
|
|
243
|
+
if (!response.ok) {
|
|
244
|
+
executions.push({ ...summary, nodeOutputs: [], nodesRun: [] });
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const body = (await response.json());
|
|
248
|
+
const decoded = typeof body.data === "string" ? unflattenExecutionData(body.data) : (body.data ?? null);
|
|
249
|
+
executions.push({
|
|
250
|
+
...summary,
|
|
251
|
+
nodesRun: listNodesRun(decoded),
|
|
252
|
+
nodeOutputs: extractNodeOutputs(decoded, summary.id, summary.startedAt, {
|
|
253
|
+
node: input.node,
|
|
254
|
+
fields: input.fields,
|
|
255
|
+
}),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return { executions, hasMore };
|
|
259
|
+
}
|
package/dist/op-cli.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one remedy for every "op isn't usable" path — shared by `ia doctor`,
|
|
3
|
+
* `ia env fill`, `ia env push` and the wizard's next steps, so the advice
|
|
4
|
+
* can't drift between them.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately does NOT tell anyone to run `op signin`. A session from
|
|
7
|
+
* `eval $(op signin)` lives in the environment of the single shell that
|
|
8
|
+
* created it, so `ia env fill` succeeds in that one window and reports every
|
|
9
|
+
* shared var as `not-in-vault` in any other — indistinguishable from never
|
|
10
|
+
* having been granted the vault. The desktop app integration authenticates op
|
|
11
|
+
* in every shell instead. It is 1Password 8 only: v7 has no Developer tab and
|
|
12
|
+
* fails with "operation not supported by device".
|
|
13
|
+
*
|
|
14
|
+
* Platform-aware because the macOS advice is actively wrong on Windows:
|
|
15
|
+
* 1Password documents PowerShell as the ONLY supported Windows shell, so the
|
|
16
|
+
* desktop-app integration cannot authenticate `op` from Git Bash at all. A
|
|
17
|
+
* technician following `brew install` text on Windows loses an hour finding
|
|
18
|
+
* that out. See platform.ts for why we don't try to tell PowerShell from cmd.
|
|
19
|
+
*/
|
|
20
|
+
import { type PlatformInfo } from "./platform.js";
|
|
21
|
+
/**
|
|
22
|
+
* How to make `op` authenticate in every shell on this machine. Callers pass
|
|
23
|
+
* the detected platform; omit it and the running machine is used.
|
|
24
|
+
*/
|
|
25
|
+
export declare function opIntegrationFix(info?: PlatformInfo): string;
|
|
26
|
+
/** Same, prefixed with the install step, for when op isn't on PATH at all. */
|
|
27
|
+
export declare function opInstallFix(info?: PlatformInfo): string;
|
|
28
|
+
/** The package-manager one-liner that puts `op` on PATH for this platform. */
|
|
29
|
+
export declare function opInstallCommand(info?: PlatformInfo): string;
|