@installagent/sdk 0.1.0 → 0.3.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-mirror.d.ts +69 -0
- package/dist/agent-mirror.js +275 -0
- package/dist/agent-templates.d.ts +36 -2
- package/dist/agent-templates.js +173 -3
- package/dist/claude-hours.d.ts +118 -0
- package/dist/claude-hours.js +523 -0
- package/dist/client-drive.d.ts +3 -0
- package/dist/client-drive.js +2 -2
- 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 +55 -13
- package/dist/env-push.d.ts +3 -0
- package/dist/env-push.js +11 -6
- package/dist/env-registry.d.ts +29 -0
- package/dist/env-registry.js +123 -9
- package/dist/exec.js +15 -2
- package/dist/git.d.ts +31 -0
- package/dist/git.js +59 -0
- package/dist/google-service-account.d.ts +20 -0
- package/dist/google-service-account.js +49 -0
- package/dist/hours-estimate.d.ts +43 -0
- package/dist/hours-estimate.js +159 -0
- package/dist/hours-export-schedule.d.ts +35 -0
- package/dist/hours-export-schedule.js +188 -0
- package/dist/hours-ledger.d.ts +129 -0
- package/dist/hours-ledger.js +882 -0
- package/dist/index.d.ts +25 -6
- package/dist/index.js +25 -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 +108 -0
- package/dist/portal-admin.js +94 -1
- package/dist/standup.d.ts +88 -0
- package/dist/standup.js +235 -0
- package/dist/sync-repos.d.ts +54 -0
- package/dist/sync-repos.js +89 -0
- package/dist/template-sync.d.ts +11 -0
- package/dist/template-sync.js +16 -0
- package/dist/triage-backfill.d.ts +37 -0
- package/dist/triage-backfill.js +211 -0
- package/dist/triage-enable.d.ts +90 -0
- package/dist/triage-enable.js +428 -0
- package/dist/triage-gates.d.ts +252 -0
- package/dist/triage-gates.js +951 -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/dist/workspace-push.d.ts +39 -0
- package/dist/workspace-push.js +78 -0
- package/dist/workspace-status.d.ts +37 -0
- package/dist/workspace-status.js +114 -0
- package/package.json +2 -2
- package/templates/env.example +37 -23
- package/templates/workspace-root/.claude/settings.json +12 -1
- 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 +127 -0
- package/templates/workspace-root/skills/CLAUDE.md +29 -6
- package/templates/workspace-root/skills/README.md +171 -0
- package/templates/workspace-root/skills/ad-machine/SKILL.md +140 -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-deliverables/SKILL.md +1 -1
- package/templates/workspace-root/skills/client-deliverables/references/package-layout.md +3 -2
- package/templates/workspace-root/skills/client-latest/SKILL.md +343 -0
- package/templates/workspace-root/skills/client-latest/catchup.command.md +18 -0
- package/templates/workspace-root/skills/cloud-devops/SKILL.md +235 -0
- package/templates/workspace-root/skills/email-triage-rollout/SKILL.md +258 -0
- package/templates/workspace-root/skills/engagement-spec/SKILL.md +51 -18
- package/templates/workspace-root/skills/engagement-spec/references/spec-templates.md +10 -4
- package/templates/workspace-root/skills/gcloud-cli-setup/SKILL.md +100 -0
- package/templates/workspace-root/skills/github-profile/SKILL.md +106 -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 +49 -7
- package/templates/workspace-root/skills/init_repo/SKILL.md +188 -0
- 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/op-cli.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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 { detectPlatformInfo, opNeedsAnotherShell } from "./platform.js";
|
|
21
|
+
const V8_NOTE = 'tick "Integrate with 1Password CLI" (v7 has no Developer tab — install v8 from 1password.com/downloads)';
|
|
22
|
+
const NO_SIGNIN_NOTE = "Don't rely on `op signin` alone — it scopes the session to the one shell that ran it";
|
|
23
|
+
/**
|
|
24
|
+
* How to make `op` authenticate in every shell on this machine. Callers pass
|
|
25
|
+
* the detected platform; omit it and the running machine is used.
|
|
26
|
+
*/
|
|
27
|
+
export function opIntegrationFix(info = detectPlatformInfo()) {
|
|
28
|
+
if (opNeedsAnotherShell(info)) {
|
|
29
|
+
return ("`op` cannot reach the 1Password desktop app from Git Bash — 1Password supports PowerShell only on " +
|
|
30
|
+
"Windows. Re-run this command in PowerShell. In the 1Password 8 desktop app go to Settings → Developer and " +
|
|
31
|
+
`${V8_NOTE}, then \`op whoami\` works in any PowerShell window. ${NO_SIGNIN_NOTE}`);
|
|
32
|
+
}
|
|
33
|
+
if (info.platform === "win32") {
|
|
34
|
+
return ("turn on the desktop app integration (1Password 8 → Settings → Developer → " +
|
|
35
|
+
`${V8_NOTE}; Settings → Security → Windows Hello unlock makes it seamless), then \`op whoami\` works in ` +
|
|
36
|
+
`every PowerShell window. ${NO_SIGNIN_NOTE}`);
|
|
37
|
+
}
|
|
38
|
+
return ("turn on the desktop app integration (1Password 8 → Settings → Developer → " +
|
|
39
|
+
`${V8_NOTE}), then \`op whoami\` works in every shell. ${NO_SIGNIN_NOTE}`);
|
|
40
|
+
}
|
|
41
|
+
/** Same, prefixed with the install step, for when op isn't on PATH at all. */
|
|
42
|
+
export function opInstallFix(info = detectPlatformInfo()) {
|
|
43
|
+
return `install the 1Password CLI (${opInstallCommand(info)}), then ${opIntegrationFix(info)}`;
|
|
44
|
+
}
|
|
45
|
+
/** The package-manager one-liner that puts `op` on PATH for this platform. */
|
|
46
|
+
export function opInstallCommand(info = detectPlatformInfo()) {
|
|
47
|
+
if (info.platform === "win32")
|
|
48
|
+
return "`winget install 1password-cli` from PowerShell";
|
|
49
|
+
if (info.platform === "linux")
|
|
50
|
+
return "see 1password.com/downloads/linux";
|
|
51
|
+
return "`brew install 1password-cli`";
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which machine (and which shell) an `ia` command is running on, so fix-it
|
|
3
|
+
* text can name the right installer and the right terminal instead of always
|
|
4
|
+
* saying `brew`.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately narrow. The only shell distinction that changes any advice is
|
|
7
|
+
* Git Bash on Windows: 1Password's own docs list PowerShell as the sole
|
|
8
|
+
* supported Windows shell, so the desktop-app CLI integration cannot
|
|
9
|
+
* authenticate `op` from an MSYS shell. Everything else (PowerShell, cmd,
|
|
10
|
+
* Windows Terminal) behaves the same for our purposes, so we do not guess
|
|
11
|
+
* between them — there is no reliable env marker that separates PowerShell
|
|
12
|
+
* from cmd, and a wrong guess would print worse advice than none.
|
|
13
|
+
*/
|
|
14
|
+
export type Platform = "darwin" | "win32" | "linux";
|
|
15
|
+
/**
|
|
16
|
+
* `gitbash` — an MSYS/MinGW bash on Windows, where `op` cannot reach the
|
|
17
|
+
* desktop app. `windows-native` — PowerShell or cmd, where it can.
|
|
18
|
+
* `posix` — macOS or Linux.
|
|
19
|
+
*/
|
|
20
|
+
export type Shell = "gitbash" | "windows-native" | "posix";
|
|
21
|
+
export interface PlatformInfo {
|
|
22
|
+
platform: Platform;
|
|
23
|
+
shell: Shell;
|
|
24
|
+
}
|
|
25
|
+
/** Anything that isn't macOS or Windows is treated as Linux. */
|
|
26
|
+
export declare function detectPlatform(platformImpl?: string): Platform;
|
|
27
|
+
/**
|
|
28
|
+
* Git Bash sets MSYSTEM (MINGW64, MINGW32, MSYS) — it is the marker Git for
|
|
29
|
+
* Windows itself uses, and the only one present in every MSYS shell whether
|
|
30
|
+
* launched from the Start menu, a terminal profile, or an IDE.
|
|
31
|
+
*/
|
|
32
|
+
export declare function detectShell(platform: Platform, env?: Record<string, string | undefined>): Shell;
|
|
33
|
+
export declare function detectPlatformInfo(env?: Record<string, string | undefined>, platformImpl?: string): PlatformInfo;
|
|
34
|
+
/** True when `op` cannot reach the 1Password desktop app from this shell. */
|
|
35
|
+
export declare function opNeedsAnotherShell(info: PlatformInfo): boolean;
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which machine (and which shell) an `ia` command is running on, so fix-it
|
|
3
|
+
* text can name the right installer and the right terminal instead of always
|
|
4
|
+
* saying `brew`.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately narrow. The only shell distinction that changes any advice is
|
|
7
|
+
* Git Bash on Windows: 1Password's own docs list PowerShell as the sole
|
|
8
|
+
* supported Windows shell, so the desktop-app CLI integration cannot
|
|
9
|
+
* authenticate `op` from an MSYS shell. Everything else (PowerShell, cmd,
|
|
10
|
+
* Windows Terminal) behaves the same for our purposes, so we do not guess
|
|
11
|
+
* between them — there is no reliable env marker that separates PowerShell
|
|
12
|
+
* from cmd, and a wrong guess would print worse advice than none.
|
|
13
|
+
*/
|
|
14
|
+
/** Anything that isn't macOS or Windows is treated as Linux. */
|
|
15
|
+
export function detectPlatform(platformImpl = process.platform) {
|
|
16
|
+
if (platformImpl === "darwin")
|
|
17
|
+
return "darwin";
|
|
18
|
+
if (platformImpl === "win32")
|
|
19
|
+
return "win32";
|
|
20
|
+
return "linux";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Git Bash sets MSYSTEM (MINGW64, MINGW32, MSYS) — it is the marker Git for
|
|
24
|
+
* Windows itself uses, and the only one present in every MSYS shell whether
|
|
25
|
+
* launched from the Start menu, a terminal profile, or an IDE.
|
|
26
|
+
*/
|
|
27
|
+
export function detectShell(platform, env = process.env) {
|
|
28
|
+
if (platform !== "win32")
|
|
29
|
+
return "posix";
|
|
30
|
+
return typeof env.MSYSTEM === "string" && env.MSYSTEM.length > 0 ? "gitbash" : "windows-native";
|
|
31
|
+
}
|
|
32
|
+
export function detectPlatformInfo(env = process.env, platformImpl = process.platform) {
|
|
33
|
+
const platform = detectPlatform(platformImpl);
|
|
34
|
+
return { platform, shell: detectShell(platform, env) };
|
|
35
|
+
}
|
|
36
|
+
/** True when `op` cannot reach the 1Password desktop app from this shell. */
|
|
37
|
+
export function opNeedsAnotherShell(info) {
|
|
38
|
+
return info.shell === "gitbash";
|
|
39
|
+
}
|
package/dist/portal-admin.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ export declare const PORTAL_SYNC_MAX_DAYS = 90;
|
|
|
6
6
|
/** Thrown when the portal admin secret is missing or rejected. */
|
|
7
7
|
export declare class PortalAdminAuthError extends Error {
|
|
8
8
|
}
|
|
9
|
+
/** Any other non-2xx answer: the status and the server's own message, for callers that branch on them. */
|
|
10
|
+
export declare class PortalRequestError extends Error {
|
|
11
|
+
readonly status: number;
|
|
12
|
+
readonly serverError: string | null;
|
|
13
|
+
constructor(message: string, status: number, serverError: string | null);
|
|
14
|
+
}
|
|
15
|
+
export type PortalTriageProvider = "gmail" | "outlook";
|
|
9
16
|
export interface PortalAdminOptions {
|
|
10
17
|
/** Bearer secret; defaults to $IA_PORTAL_ADMIN_SECRET. */
|
|
11
18
|
secret?: string;
|
|
@@ -27,6 +34,8 @@ export interface PortalOrg {
|
|
|
27
34
|
status: string;
|
|
28
35
|
driveFolderId: string | null;
|
|
29
36
|
airtableRecordId: string | null;
|
|
37
|
+
/** The client channel the weekly triage digest posts to; null = no digest. */
|
|
38
|
+
slackChannelId?: string | null;
|
|
30
39
|
users: PortalOrgUser[];
|
|
31
40
|
}
|
|
32
41
|
export interface PortalAgent {
|
|
@@ -38,6 +47,8 @@ export interface PortalAgent {
|
|
|
38
47
|
status: "active" | "paused" | "retired";
|
|
39
48
|
n8nActive: boolean | null;
|
|
40
49
|
lastSyncedAt: string | null;
|
|
50
|
+
/** Set = an email-triage agent of that provider. Absent on portals older than 2026-09-29. */
|
|
51
|
+
triageProvider?: PortalTriageProvider | null;
|
|
41
52
|
}
|
|
42
53
|
export interface PortalCreateOrgInput {
|
|
43
54
|
slug: string;
|
|
@@ -92,6 +103,34 @@ export interface PortalSetAgentStatusResult {
|
|
|
92
103
|
agent: string;
|
|
93
104
|
status: "active" | "paused" | "retired";
|
|
94
105
|
}
|
|
106
|
+
export interface PortalSetAgentNameInput {
|
|
107
|
+
slug: string;
|
|
108
|
+
agent: string;
|
|
109
|
+
/** The client-facing label on the agent card. */
|
|
110
|
+
name: string;
|
|
111
|
+
}
|
|
112
|
+
export interface PortalSetAgentNameResult {
|
|
113
|
+
org: string;
|
|
114
|
+
agent: string;
|
|
115
|
+
previousName: string;
|
|
116
|
+
name: string;
|
|
117
|
+
/** False when the name was already that — the call is idempotent. */
|
|
118
|
+
changed: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface PortalSetAgentWorkflowInput {
|
|
121
|
+
slug: string;
|
|
122
|
+
agent: string;
|
|
123
|
+
/** The n8n workflow id the agent should report as from now on. */
|
|
124
|
+
workflowId: string;
|
|
125
|
+
}
|
|
126
|
+
export interface PortalSetAgentWorkflowResult {
|
|
127
|
+
org: string;
|
|
128
|
+
agent: string;
|
|
129
|
+
previousWorkflowId: string;
|
|
130
|
+
workflowId: string;
|
|
131
|
+
/** False when the agent already pointed there — the call is idempotent. */
|
|
132
|
+
changed: boolean;
|
|
133
|
+
}
|
|
95
134
|
export interface PortalListAgentsResult {
|
|
96
135
|
agents: PortalAgent[];
|
|
97
136
|
}
|
|
@@ -125,9 +164,78 @@ export declare function portalCreateAgent(input: PortalCreateAgentInput, options
|
|
|
125
164
|
agent: PortalAgent;
|
|
126
165
|
}>;
|
|
127
166
|
export declare function portalSetAgentStatus(input: PortalSetAgentStatusInput, options?: PortalAdminOptions): Promise<PortalSetAgentStatusResult>;
|
|
167
|
+
/**
|
|
168
|
+
* Rename an agent — the client-facing label on its card. The agent slug is the
|
|
169
|
+
* stable identifier, so a rename breaks no reference.
|
|
170
|
+
*/
|
|
171
|
+
export declare function portalSetAgentName(input: PortalSetAgentNameInput, options?: PortalAdminOptions): Promise<PortalSetAgentNameResult>;
|
|
172
|
+
/**
|
|
173
|
+
* Repoint an agent at a different n8n workflow — for a version bump (v2
|
|
174
|
+
* replacing a retired v1), which is the same agent from the client's side.
|
|
175
|
+
* The row keeps its slug, name, and run history; the portal re-observes the
|
|
176
|
+
* new workflow's live state on the next sync.
|
|
177
|
+
*/
|
|
178
|
+
export declare function portalSetAgentWorkflow(input: PortalSetAgentWorkflowInput, options?: PortalAdminOptions): Promise<PortalSetAgentWorkflowResult>;
|
|
128
179
|
export declare function portalListAgents(input?: {
|
|
129
180
|
slug?: string;
|
|
130
181
|
}, options?: PortalAdminOptions): Promise<PortalListAgentsResult>;
|
|
131
182
|
export declare function portalSyncRuns(input?: {
|
|
132
183
|
days?: number;
|
|
133
184
|
}, options?: PortalAdminOptions): Promise<PortalSyncRunsResult>;
|
|
185
|
+
export interface PortalSetAgentTriageResult {
|
|
186
|
+
org: string;
|
|
187
|
+
agent: string;
|
|
188
|
+
triageProvider: PortalTriageProvider | null;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Mark an agent as an email-triage agent of one provider, or clear it with
|
|
192
|
+
* null. Only a triage agent may write classification rows, and the provider
|
|
193
|
+
* decides the row shape the portal accepts.
|
|
194
|
+
*/
|
|
195
|
+
export declare function portalSetAgentTriage(input: {
|
|
196
|
+
slug: string;
|
|
197
|
+
agent: string;
|
|
198
|
+
provider: PortalTriageProvider | null;
|
|
199
|
+
}, options?: PortalAdminOptions): Promise<PortalSetAgentTriageResult>;
|
|
200
|
+
/** Where the weekly triage digest posts for this client; null = no digest. */
|
|
201
|
+
export declare function portalSetOrgSlackChannel(input: {
|
|
202
|
+
slug: string;
|
|
203
|
+
channelId: string | null;
|
|
204
|
+
}, options?: PortalAdminOptions): Promise<{
|
|
205
|
+
slug: string;
|
|
206
|
+
slackChannelId: string | null;
|
|
207
|
+
}>;
|
|
208
|
+
export interface PortalTriageRecordsPage {
|
|
209
|
+
org: string;
|
|
210
|
+
agent: string;
|
|
211
|
+
provider: PortalTriageProvider;
|
|
212
|
+
/** Record-sheet-shaped rows: the provider's own header names, every cell a string. */
|
|
213
|
+
rows: Record<string, string>[];
|
|
214
|
+
/** Cursor for the next page, or null on the last one. */
|
|
215
|
+
next: string | null;
|
|
216
|
+
}
|
|
217
|
+
/** One page of a triage agent's classification rows, oldest first. */
|
|
218
|
+
export declare function portalReadTriageRecords(input: {
|
|
219
|
+
org: string;
|
|
220
|
+
agent?: string;
|
|
221
|
+
since?: Date;
|
|
222
|
+
until?: Date;
|
|
223
|
+
after?: string;
|
|
224
|
+
limit?: number;
|
|
225
|
+
}, options?: PortalAdminOptions): Promise<PortalTriageRecordsPage>;
|
|
226
|
+
export interface PortalTriageBackfillResult {
|
|
227
|
+
org: string;
|
|
228
|
+
agent: string;
|
|
229
|
+
received: number;
|
|
230
|
+
inserted: number;
|
|
231
|
+
duplicates: number;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* One backfill batch of record-sheet rows (the portal accepts 1–500). The
|
|
235
|
+
* insert is idempotent on (agent, message_id), so a re-run inserts nothing.
|
|
236
|
+
*/
|
|
237
|
+
export declare function portalBackfillTriageRecords(input: {
|
|
238
|
+
org: string;
|
|
239
|
+
agent?: string;
|
|
240
|
+
rows: Record<string, string>[];
|
|
241
|
+
}, options?: PortalAdminOptions): Promise<PortalTriageBackfillResult>;
|
package/dist/portal-admin.js
CHANGED
|
@@ -18,6 +18,16 @@ export const PORTAL_SYNC_MAX_DAYS = 90;
|
|
|
18
18
|
/** Thrown when the portal admin secret is missing or rejected. */
|
|
19
19
|
export class PortalAdminAuthError extends Error {
|
|
20
20
|
}
|
|
21
|
+
/** Any other non-2xx answer: the status and the server's own message, for callers that branch on them. */
|
|
22
|
+
export class PortalRequestError extends Error {
|
|
23
|
+
status;
|
|
24
|
+
serverError;
|
|
25
|
+
constructor(message, status, serverError) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.status = status;
|
|
28
|
+
this.serverError = serverError;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
21
31
|
/** Lowercase then validate, matching the server (and the old script). */
|
|
22
32
|
function normalizeSlug(value, field) {
|
|
23
33
|
const slug = value.toLowerCase();
|
|
@@ -53,7 +63,7 @@ async function portalRequest(method, path, options, body) {
|
|
|
53
63
|
? String(data.error)
|
|
54
64
|
: null)
|
|
55
65
|
.catch(() => null);
|
|
56
|
-
throw new
|
|
66
|
+
throw new PortalRequestError(`${method} ${path} failed: HTTP ${res.status}${serverError ? ` — ${serverError}` : ""}`, res.status, serverError);
|
|
57
67
|
}
|
|
58
68
|
return (await res.json());
|
|
59
69
|
}
|
|
@@ -118,6 +128,36 @@ export async function portalSetAgentStatus(input, options = {}) {
|
|
|
118
128
|
status: input.status,
|
|
119
129
|
});
|
|
120
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Rename an agent — the client-facing label on its card. The agent slug is the
|
|
133
|
+
* stable identifier, so a rename breaks no reference.
|
|
134
|
+
*/
|
|
135
|
+
export async function portalSetAgentName(input, options = {}) {
|
|
136
|
+
const slug = normalizeSlug(input.slug, "org");
|
|
137
|
+
const agent = normalizeSlug(input.agent, "agent");
|
|
138
|
+
const name = input.name.trim();
|
|
139
|
+
if (!name)
|
|
140
|
+
throw new Error("name required");
|
|
141
|
+
return portalRequest("POST", "/api/admin/agents/name", options, { slug, agent, name });
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Repoint an agent at a different n8n workflow — for a version bump (v2
|
|
145
|
+
* replacing a retired v1), which is the same agent from the client's side.
|
|
146
|
+
* The row keeps its slug, name, and run history; the portal re-observes the
|
|
147
|
+
* new workflow's live state on the next sync.
|
|
148
|
+
*/
|
|
149
|
+
export async function portalSetAgentWorkflow(input, options = {}) {
|
|
150
|
+
const slug = normalizeSlug(input.slug, "org");
|
|
151
|
+
const agent = normalizeSlug(input.agent, "agent");
|
|
152
|
+
const workflowId = input.workflowId.trim();
|
|
153
|
+
if (!workflowId)
|
|
154
|
+
throw new Error("workflowId required");
|
|
155
|
+
return portalRequest("POST", "/api/admin/agents/workflow-id", options, {
|
|
156
|
+
slug,
|
|
157
|
+
agent,
|
|
158
|
+
workflowId,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
121
161
|
export async function portalListAgents(input = {}, options = {}) {
|
|
122
162
|
const query = input.slug ? `?slug=${encodeURIComponent(normalizeSlug(input.slug, "org"))}` : "";
|
|
123
163
|
return portalRequest("GET", `/api/admin/agents${query}`, options);
|
|
@@ -142,3 +182,56 @@ export async function portalSyncRuns(input = {}, options = {}) {
|
|
|
142
182
|
throw new Error(`${message} (the sync is idempotent — safe to re-run, or use a smaller --days)`);
|
|
143
183
|
}
|
|
144
184
|
}
|
|
185
|
+
// ─── Email-triage record (the portal's triage_classifications) ─────────────
|
|
186
|
+
function assertProvider(provider) {
|
|
187
|
+
if (provider !== null && provider !== "gmail" && provider !== "outlook") {
|
|
188
|
+
throw new Error("provider must be gmail|outlook, or null to clear it");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Mark an agent as an email-triage agent of one provider, or clear it with
|
|
193
|
+
* null. Only a triage agent may write classification rows, and the provider
|
|
194
|
+
* decides the row shape the portal accepts.
|
|
195
|
+
*/
|
|
196
|
+
export async function portalSetAgentTriage(input, options = {}) {
|
|
197
|
+
const slug = normalizeSlug(input.slug, "org");
|
|
198
|
+
const agent = normalizeSlug(input.agent, "agent");
|
|
199
|
+
assertProvider(input.provider);
|
|
200
|
+
return portalRequest("POST", "/api/admin/agents/triage", options, {
|
|
201
|
+
slug,
|
|
202
|
+
agent,
|
|
203
|
+
provider: input.provider,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/** Where the weekly triage digest posts for this client; null = no digest. */
|
|
207
|
+
export async function portalSetOrgSlackChannel(input, options = {}) {
|
|
208
|
+
const slug = normalizeSlug(input.slug, "org");
|
|
209
|
+
const channelId = input.channelId === null ? null : input.channelId.trim();
|
|
210
|
+
return portalRequest("POST", "/api/admin/orgs/slack-channel", options, { slug, channelId });
|
|
211
|
+
}
|
|
212
|
+
/** One page of a triage agent's classification rows, oldest first. */
|
|
213
|
+
export async function portalReadTriageRecords(input, options = {}) {
|
|
214
|
+
const query = new URLSearchParams({ org: normalizeSlug(input.org, "org") });
|
|
215
|
+
if (input.agent)
|
|
216
|
+
query.set("agent", normalizeSlug(input.agent, "agent"));
|
|
217
|
+
if (input.since)
|
|
218
|
+
query.set("since", input.since.toISOString());
|
|
219
|
+
if (input.until)
|
|
220
|
+
query.set("until", input.until.toISOString());
|
|
221
|
+
if (input.after)
|
|
222
|
+
query.set("after", input.after);
|
|
223
|
+
if (input.limit !== undefined)
|
|
224
|
+
query.set("limit", String(input.limit));
|
|
225
|
+
return portalRequest("GET", `/api/admin/triage-records?${query.toString()}`, options);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* One backfill batch of record-sheet rows (the portal accepts 1–500). The
|
|
229
|
+
* insert is idempotent on (agent, message_id), so a re-run inserts nothing.
|
|
230
|
+
*/
|
|
231
|
+
export async function portalBackfillTriageRecords(input, options = {}) {
|
|
232
|
+
return portalRequest("POST", "/api/admin/triage-records", options, {
|
|
233
|
+
org: normalizeSlug(input.org, "org"),
|
|
234
|
+
...(input.agent ? { agent: normalizeSlug(input.agent, "agent") } : {}),
|
|
235
|
+
rows: input.rows,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type ExecFileFn } from "./exec.js";
|
|
2
|
+
export interface StandupGitState {
|
|
3
|
+
staged: number;
|
|
4
|
+
unstaged: number;
|
|
5
|
+
untracked: number;
|
|
6
|
+
}
|
|
7
|
+
export interface StandupRepoLint {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
/** First line of the lint output when it failed — a pointer, not the report. */
|
|
10
|
+
detail?: string;
|
|
11
|
+
}
|
|
12
|
+
export type StandupCallPrepStatus = "fresh" | "stale" | "missing-agenda" | "no-calls" | "no-registry";
|
|
13
|
+
export interface StandupCallPrep {
|
|
14
|
+
status: StandupCallPrepStatus;
|
|
15
|
+
/** ISO date of the newest registry call file, when one exists. */
|
|
16
|
+
latestCall?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface StandupIssueRef {
|
|
19
|
+
identifier: string;
|
|
20
|
+
title: string;
|
|
21
|
+
state: string;
|
|
22
|
+
}
|
|
23
|
+
export type StandupLinear = {
|
|
24
|
+
status: "ok";
|
|
25
|
+
open: number;
|
|
26
|
+
inProgress: number;
|
|
27
|
+
next: StandupIssueRef | null;
|
|
28
|
+
} | {
|
|
29
|
+
status: "skipped";
|
|
30
|
+
reason: string;
|
|
31
|
+
} | {
|
|
32
|
+
status: "error";
|
|
33
|
+
reason: string;
|
|
34
|
+
};
|
|
35
|
+
export interface StandupRepo {
|
|
36
|
+
slug: string;
|
|
37
|
+
dir: string;
|
|
38
|
+
/** null when `git status` itself failed (detail in gitError). */
|
|
39
|
+
git: StandupGitState | null;
|
|
40
|
+
gitError?: string;
|
|
41
|
+
/** null when the repo has no ci/repo-lint.mjs to run. */
|
|
42
|
+
repoLint: StandupRepoLint | null;
|
|
43
|
+
hooksInstalled: boolean;
|
|
44
|
+
/** Newest ISO date found in docs/00-delivery-log.md, or null. */
|
|
45
|
+
lastShipped: string | null;
|
|
46
|
+
lastShippedAgeDays: number | null;
|
|
47
|
+
callPrep: StandupCallPrep;
|
|
48
|
+
linear: StandupLinear;
|
|
49
|
+
/** Human-ready flags, worst first — empty means nothing needs attention. */
|
|
50
|
+
attention: string[];
|
|
51
|
+
}
|
|
52
|
+
export interface StandupStaleTodo {
|
|
53
|
+
/** Workspace-relative path, e.g. "team-web/todo/posthog-integration.md". */
|
|
54
|
+
file: string;
|
|
55
|
+
ageDays: number;
|
|
56
|
+
}
|
|
57
|
+
export interface StandupResult {
|
|
58
|
+
workspaceDir: string;
|
|
59
|
+
generatedAt: string;
|
|
60
|
+
/** False when Linear was skipped (offline, or no $LINEAR_API_TOKEN). */
|
|
61
|
+
linearEnabled: boolean;
|
|
62
|
+
/** Most actionable first. */
|
|
63
|
+
repos: StandupRepo[];
|
|
64
|
+
staleTodos: StandupStaleTodo[];
|
|
65
|
+
}
|
|
66
|
+
export interface StandupOptions {
|
|
67
|
+
/** The installagent/ workspace root (contains clients/, team-clients/). */
|
|
68
|
+
workspaceDir?: string;
|
|
69
|
+
/** Skip the Linear reads entirely — everything else is local. */
|
|
70
|
+
offline?: boolean;
|
|
71
|
+
/** Linear API key; defaults to $LINEAR_API_TOKEN. */
|
|
72
|
+
linearToken?: string;
|
|
73
|
+
/** Injectable for tests. */
|
|
74
|
+
execFileImpl?: ExecFileFn;
|
|
75
|
+
fetchImpl?: typeof fetch;
|
|
76
|
+
env?: NodeJS.ProcessEnv;
|
|
77
|
+
now?: () => Date;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Cross-client morning report: for every clients/client-* checkout — git
|
|
81
|
+
* state, repo-lint, lefthook hooks, delivery-log recency, call-prep
|
|
82
|
+
* freshness, and the client's open Linear issues — plus workspace todo/
|
|
83
|
+
* files older than 30 days. Strictly read-only, by decision: it reports and
|
|
84
|
+
* never fixes (fixes route to `ia template-sync`, `npx lefthook install`,
|
|
85
|
+
* `ia client <slug>`). The only network calls are Linear reads, skipped
|
|
86
|
+
* gracefully when offline or the token is absent.
|
|
87
|
+
*/
|
|
88
|
+
export declare function standup(options?: StandupOptions): Promise<StandupResult>;
|