gws-axi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/dist/bin/gws-axi.d.ts +2 -0
  4. package/dist/bin/gws-axi.js +4 -0
  5. package/dist/bin/gws-axi.js.map +1 -0
  6. package/dist/src/auth/gcloud.d.ts +21 -0
  7. package/dist/src/auth/gcloud.js +134 -0
  8. package/dist/src/auth/gcloud.js.map +1 -0
  9. package/dist/src/auth/loopback.d.ts +50 -0
  10. package/dist/src/auth/loopback.js +420 -0
  11. package/dist/src/auth/loopback.js.map +1 -0
  12. package/dist/src/auth/pending.d.ts +15 -0
  13. package/dist/src/auth/pending.js +35 -0
  14. package/dist/src/auth/pending.js.map +1 -0
  15. package/dist/src/auth/scopes.d.ts +13 -0
  16. package/dist/src/auth/scopes.js +29 -0
  17. package/dist/src/auth/scopes.js.map +1 -0
  18. package/dist/src/auth/setup-html.d.ts +13 -0
  19. package/dist/src/auth/setup-html.js +245 -0
  20. package/dist/src/auth/setup-html.js.map +1 -0
  21. package/dist/src/auth/state.d.ts +4 -0
  22. package/dist/src/auth/state.js +41 -0
  23. package/dist/src/auth/state.js.map +1 -0
  24. package/dist/src/auth/steps.d.ts +30 -0
  25. package/dist/src/auth/steps.js +306 -0
  26. package/dist/src/auth/steps.js.map +1 -0
  27. package/dist/src/cli.d.ts +2 -0
  28. package/dist/src/cli.js +72 -0
  29. package/dist/src/cli.js.map +1 -0
  30. package/dist/src/commands/auth.d.ts +2 -0
  31. package/dist/src/commands/auth.js +453 -0
  32. package/dist/src/commands/auth.js.map +1 -0
  33. package/dist/src/commands/calendar/calendars.d.ts +2 -0
  34. package/dist/src/commands/calendar/calendars.js +98 -0
  35. package/dist/src/commands/calendar/calendars.js.map +1 -0
  36. package/dist/src/commands/calendar/events.d.ts +2 -0
  37. package/dist/src/commands/calendar/events.js +261 -0
  38. package/dist/src/commands/calendar/events.js.map +1 -0
  39. package/dist/src/commands/calendar/get.d.ts +2 -0
  40. package/dist/src/commands/calendar/get.js +176 -0
  41. package/dist/src/commands/calendar/get.js.map +1 -0
  42. package/dist/src/commands/calendar.d.ts +2 -0
  43. package/dist/src/commands/calendar.js +76 -0
  44. package/dist/src/commands/calendar.js.map +1 -0
  45. package/dist/src/commands/docs.d.ts +2 -0
  46. package/dist/src/commands/docs.js +19 -0
  47. package/dist/src/commands/docs.js.map +1 -0
  48. package/dist/src/commands/doctor.d.ts +2 -0
  49. package/dist/src/commands/doctor.js +213 -0
  50. package/dist/src/commands/doctor.js.map +1 -0
  51. package/dist/src/commands/drive.d.ts +2 -0
  52. package/dist/src/commands/drive.js +17 -0
  53. package/dist/src/commands/drive.js.map +1 -0
  54. package/dist/src/commands/gmail.d.ts +2 -0
  55. package/dist/src/commands/gmail.js +20 -0
  56. package/dist/src/commands/gmail.js.map +1 -0
  57. package/dist/src/commands/home.d.ts +1 -0
  58. package/dist/src/commands/home.js +42 -0
  59. package/dist/src/commands/home.js.map +1 -0
  60. package/dist/src/commands/service-stub.d.ts +8 -0
  61. package/dist/src/commands/service-stub.js +67 -0
  62. package/dist/src/commands/service-stub.js.map +1 -0
  63. package/dist/src/commands/slides.d.ts +2 -0
  64. package/dist/src/commands/slides.js +11 -0
  65. package/dist/src/commands/slides.js.map +1 -0
  66. package/dist/src/config.d.ts +46 -0
  67. package/dist/src/config.js +155 -0
  68. package/dist/src/config.js.map +1 -0
  69. package/dist/src/google/account.d.ts +12 -0
  70. package/dist/src/google/account.js +65 -0
  71. package/dist/src/google/account.js.map +1 -0
  72. package/dist/src/google/client.d.ts +29 -0
  73. package/dist/src/google/client.js +106 -0
  74. package/dist/src/google/client.js.map +1 -0
  75. package/dist/src/google/probe.d.ts +15 -0
  76. package/dist/src/google/probe.js +200 -0
  77. package/dist/src/google/probe.js.map +1 -0
  78. package/dist/src/google/tokens.d.ts +22 -0
  79. package/dist/src/google/tokens.js +91 -0
  80. package/dist/src/google/tokens.js.map +1 -0
  81. package/dist/src/output/index.d.ts +2 -0
  82. package/dist/src/output/index.js +3 -0
  83. package/dist/src/output/index.js.map +1 -0
  84. package/dist/src/output/render.d.ts +40 -0
  85. package/dist/src/output/render.js +65 -0
  86. package/dist/src/output/render.js.map +1 -0
  87. package/dist/src/output/schema.d.ts +32 -0
  88. package/dist/src/output/schema.js +69 -0
  89. package/dist/src/output/schema.js.map +1 -0
  90. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jarvus Innovations
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # gws-axi
2
+
3
+ Agent-ergonomic CLI for Google Workspace — Gmail, Calendar, Docs, Drive, and Slides behind a single command, built to the [AXI standard](https://axi.md): [TOON](https://toonformat.dev/)-formatted output, contextual next-step suggestions, idempotent mutations, and multi-account safety by default.
4
+
5
+ Designed for use by AI agents. Every response is structured, every error names a specific fix, and write operations lock to the explicit account when multiple are authenticated — so two agents in parallel sessions can't silently touch the wrong mailbox.
6
+
7
+ > **Status:** early release. **Calendar reads** (`calendar events`) are implemented with real TOON output. Other subcommands (`calendar get|create|update|…`, `gmail`, `docs`, `drive`, `slides`) are scaffolded but return `NOT_IMPLEMENTED`. Auth, doctor, and multi-account management are complete.
8
+
9
+ ## Requirements
10
+
11
+ - Node.js ≥ 20
12
+ - A Google account (personal or Workspace)
13
+ - `gcloud` CLI (optional — speeds up initial setup, not required)
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -g gws-axi
19
+ ```
20
+
21
+ ## First-run setup
22
+
23
+ `gws-axi` uses a **bring-your-own OAuth client** model: you create your own Google Cloud project with OAuth credentials, and tokens live locally at `~/.config/gws-axi/`. This avoids verification/CASA overhead for public apps and keeps the blast radius of any token revocation scoped to you.
24
+
25
+ The setup is progressive — run `gws-axi auth setup` repeatedly and each invocation walks you through the next step:
26
+
27
+ ```bash
28
+ gws-axi auth setup # start or continue — 7 steps, mostly automated
29
+ gws-axi doctor # check setup + live API health at any time
30
+ ```
31
+
32
+ The CLI generates a styled, auto-refreshing HTML helper page at `~/.config/gws-axi/setup.html` with clickable Console deep-links — so you never copy long URLs from terminal to browser and you stay in the right browser profile throughout.
33
+
34
+ Typical flow: set project → enable APIs → create OAuth client → download JSON → configure consent screen → add test users → authenticate. See the in-CLI guidance as you go; every step tells you exactly what to do next.
35
+
36
+ ## Usage
37
+
38
+ Every subcommand supports `--help`. The bare `gws-axi` command prints current state, authenticated accounts, and top suggestions.
39
+
40
+ ```bash
41
+ gws-axi # home view
42
+ gws-axi calendar events # list upcoming events
43
+ gws-axi calendar events --query standup # full-text search
44
+ gws-axi calendar events --fields attendees,location
45
+ gws-axi auth accounts # list authenticated Google accounts
46
+ gws-axi auth login --account <email> # add another account
47
+ gws-axi doctor # full health check
48
+ ```
49
+
50
+ ### Multi-account with write protection
51
+
52
+ gws-axi supports multiple Google accounts under one OAuth client. When two or more are authenticated, write operations require `--account <email>` explicitly — silent wrong-account mutations are impossible:
53
+
54
+ ```bash
55
+ gws-axi calendar events # read: uses default account
56
+ gws-axi calendar create --summary "..." # write: ACCOUNT_REQUIRED error
57
+ gws-axi calendar create --account chris@jarv.us --summary "..." # OK
58
+ ```
59
+
60
+ ### Example output
61
+
62
+ ```
63
+ account: chris@jarv.us
64
+ count: 3
65
+ range: 2026-04-20T14:00:00.000Z → 2026-04-27T14:00:00.000Z
66
+ events[3]{id,summary,start,end,my_response}:
67
+ abc123,Team standup,2026-04-21T14:00:00-04:00,2026-04-21T14:15:00-04:00,accepted
68
+ def456,1:1 with Ari,2026-04-22T15:30:00-04:00,2026-04-22T16:00:00-04:00,accepted
69
+ ghi789,Board meeting,2026-04-25,2026-04-26,needsAction
70
+ help[2]:
71
+ Run `gws-axi calendar get <id>` for full event details
72
+ Add `--fields attendees,location,status` to show more columns
73
+ ```
74
+
75
+ ## Design docs
76
+
77
+ - [`docs/design.md`](https://github.com/JarvusInnovations/gws-axi/blob/main/docs/design.md) — architecture, auth model, doctor tiers, command surface
78
+ - [`docs/shared-client-future.md`](https://github.com/JarvusInnovations/gws-axi/blob/main/docs/shared-client-future.md) — why BYO-only for v1, what a shared-client public distribution would involve
79
+
80
+ ## Known issues
81
+
82
+ - **Testing-mode tokens expire every 7 days.** Google's OAuth policy. Re-run `gws-axi auth login --wait` when it happens. A future `gws-axi auth publish` helper will walk single-developer verification to eliminate this.
83
+ - **Most service subcommands are not yet implemented.** Only `calendar events` does real work as of v0.1. The rest will follow — see the design doc for the order.
84
+
85
+ ## Contributing
86
+
87
+ Issues and PRs welcome at [github.com/JarvusInnovations/gws-axi](https://github.com/JarvusInnovations/gws-axi).
88
+
89
+ ## License
90
+
91
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../src/cli.js";
3
+ main();
4
+ //# sourceMappingURL=gws-axi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gws-axi.js","sourceRoot":"","sources":["../../bin/gws-axi.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface GcloudProject {
2
+ projectId: string;
3
+ name: string;
4
+ projectNumber: string;
5
+ }
6
+ export interface GcloudResult<T> {
7
+ ok: true;
8
+ value: T;
9
+ }
10
+ export interface GcloudError {
11
+ ok: false;
12
+ code: "NOT_INSTALLED" | "NOT_AUTHENTICATED" | "COMMAND_FAILED";
13
+ message: string;
14
+ }
15
+ export type GcloudOutcome<T> = GcloudResult<T> | GcloudError;
16
+ export declare function isGcloudInstalled(): boolean;
17
+ export declare function gcloudAccount(): GcloudOutcome<string>;
18
+ export declare function listProjects(): GcloudOutcome<GcloudProject[]>;
19
+ export declare function createProject(projectId: string, displayName: string): GcloudOutcome<GcloudProject>;
20
+ export declare function enableApis(projectId: string, apis: string[]): GcloudOutcome<true>;
21
+ export declare function listEnabledApis(projectId: string): GcloudOutcome<string[]>;
@@ -0,0 +1,134 @@
1
+ import { execFileSync } from "node:child_process";
2
+ function runGcloud(args) {
3
+ try {
4
+ const out = execFileSync("gcloud", args, {
5
+ encoding: "utf-8",
6
+ stdio: ["ignore", "pipe", "pipe"],
7
+ });
8
+ return { ok: true, value: out };
9
+ }
10
+ catch (err) {
11
+ const e = err;
12
+ if (e.code === "ENOENT") {
13
+ return {
14
+ ok: false,
15
+ code: "NOT_INSTALLED",
16
+ message: "gcloud CLI is not installed",
17
+ };
18
+ }
19
+ const stderr = typeof e.stderr === "string"
20
+ ? e.stderr
21
+ : (e.stderr?.toString("utf-8") ?? "");
22
+ if (/you do not currently have an active account|please run.*auth login/i.test(stderr)) {
23
+ return {
24
+ ok: false,
25
+ code: "NOT_AUTHENTICATED",
26
+ message: "gcloud is not authenticated — run `gcloud auth login`",
27
+ };
28
+ }
29
+ return {
30
+ ok: false,
31
+ code: "COMMAND_FAILED",
32
+ message: stderr.split("\n").filter((l) => l.trim()).slice(-1)[0] ?? "gcloud command failed",
33
+ };
34
+ }
35
+ }
36
+ export function isGcloudInstalled() {
37
+ try {
38
+ execFileSync("gcloud", ["--version"], {
39
+ stdio: ["ignore", "pipe", "ignore"],
40
+ });
41
+ return true;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ export function gcloudAccount() {
48
+ const result = runGcloud([
49
+ "auth",
50
+ "list",
51
+ "--filter=status:ACTIVE",
52
+ "--format=value(account)",
53
+ ]);
54
+ if (!result.ok)
55
+ return result;
56
+ const account = result.value.trim();
57
+ if (!account) {
58
+ return {
59
+ ok: false,
60
+ code: "NOT_AUTHENTICATED",
61
+ message: "No active gcloud account — run `gcloud auth login`",
62
+ };
63
+ }
64
+ return { ok: true, value: account };
65
+ }
66
+ export function listProjects() {
67
+ const result = runGcloud([
68
+ "projects",
69
+ "list",
70
+ "--format=json",
71
+ "--limit=100",
72
+ ]);
73
+ if (!result.ok)
74
+ return result;
75
+ try {
76
+ const parsed = JSON.parse(result.value);
77
+ return { ok: true, value: parsed };
78
+ }
79
+ catch {
80
+ return {
81
+ ok: false,
82
+ code: "COMMAND_FAILED",
83
+ message: "Failed to parse gcloud projects list output",
84
+ };
85
+ }
86
+ }
87
+ export function createProject(projectId, displayName) {
88
+ const result = runGcloud([
89
+ "projects",
90
+ "create",
91
+ projectId,
92
+ `--name=${displayName}`,
93
+ "--format=json",
94
+ ]);
95
+ if (!result.ok)
96
+ return result;
97
+ try {
98
+ const parsed = JSON.parse(result.value);
99
+ return { ok: true, value: parsed };
100
+ }
101
+ catch {
102
+ return {
103
+ ok: true,
104
+ value: { projectId, name: displayName, projectNumber: "" },
105
+ };
106
+ }
107
+ }
108
+ export function enableApis(projectId, apis) {
109
+ const result = runGcloud([
110
+ "services",
111
+ "enable",
112
+ ...apis,
113
+ `--project=${projectId}`,
114
+ ]);
115
+ if (!result.ok)
116
+ return result;
117
+ return { ok: true, value: true };
118
+ }
119
+ export function listEnabledApis(projectId) {
120
+ const result = runGcloud([
121
+ "services",
122
+ "list",
123
+ "--enabled",
124
+ `--project=${projectId}`,
125
+ "--format=value(config.name)",
126
+ ]);
127
+ if (!result.ok)
128
+ return result;
129
+ return {
130
+ ok: true,
131
+ value: result.value.split("\n").map((l) => l.trim()).filter(Boolean),
132
+ };
133
+ }
134
+ //# sourceMappingURL=gcloud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcloud.js","sourceRoot":"","sources":["../../../src/auth/gcloud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAqBlD,SAAS,SAAS,CAAC,IAAc;IAC/B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,EAAE,IAAI,EAAE;YACvC,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAClC,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,GAAkD,CAAC;QAC7D,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxB,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,6BAA6B;aACvC,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GACV,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ;YAC1B,CAAC,CAAC,CAAC,CAAC,MAAM;YACV,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1C,IAAI,qE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,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC9B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,SAAiB;IAEjB,MAAM,MAAM,GAAG,SAAS,CAAC;QACvB,UAAU;QACV,MAAM;QACN,WAAW;QACX,aAAa,SAAS,EAAE;QACxB,6BAA6B;KAC9B,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC9B,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;KACrE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type PendingAuth } from "./pending.js";
2
+ import type { StepOutcome } from "./steps.js";
3
+ export interface StoredTokens {
4
+ client_id: string;
5
+ access_token: string;
6
+ refresh_token?: string;
7
+ expiry_date: number;
8
+ scope: string;
9
+ token_type: string;
10
+ obtained_at: string;
11
+ }
12
+ export interface StoredProfile {
13
+ email: string;
14
+ verified_email: boolean;
15
+ name?: string;
16
+ picture?: string;
17
+ sub: string;
18
+ updated_at: string;
19
+ }
20
+ export interface PrepareOptions {
21
+ expectedAccount?: string;
22
+ }
23
+ export interface PrepareOutcome {
24
+ pending: PendingAuth;
25
+ htmlPath: string;
26
+ credentialsPresent: boolean;
27
+ }
28
+ /**
29
+ * Phase 1: generate the auth URL, reserve a port, persist pending state,
30
+ * write setup.html with the authenticate button. Returns immediately so the
31
+ * agent can relay instructions to the user BEFORE any process blocks on a
32
+ * callback. Call `awaitPendingAuth` after instructing the user.
33
+ */
34
+ export declare function preparePendingAuth(options?: PrepareOptions): Promise<PrepareOutcome | {
35
+ error: string;
36
+ code: string;
37
+ }>;
38
+ /**
39
+ * Phase 2: read pending state, start the callback server, block until the
40
+ * user authenticates (or timeout). Runs the token exchange, fetches the
41
+ * userinfo to identify the account, writes tokens + profile, updates
42
+ * default account if first, regenerates setup.html without the banner.
43
+ */
44
+ export declare function awaitPendingAuth(): Promise<StepOutcome>;
45
+ /**
46
+ * Helper for callers (like `auth setup`) that want to expose the prepared
47
+ * instructions to the user/agent as a StepOutcome. Does NOT block — just
48
+ * wraps preparePendingAuth into the StepOutcome shape.
49
+ */
50
+ export declare function advanceTokensObtained(options?: PrepareOptions): Promise<StepOutcome>;