@idapt/cli 1.11.0 → 1.12.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/bin.cjs CHANGED
@@ -5997,6 +5997,8 @@ var noteBoxSchema = zod.z.object({
5997
5997
  var noteSchema = zod.z.object({
5998
5998
  /** Public resourceId of the note. */
5999
5999
  id: zod.z.string(),
6000
+ /** Containing folder's resourceId, or null at the box root. */
6001
+ folder_id: zod.z.string().nullable(),
6000
6002
  title: zod.z.string(),
6001
6003
  content: zod.z.string(),
6002
6004
  /** "note" or "index". */
@@ -6006,6 +6008,38 @@ var noteSchema = zod.z.object({
6006
6008
  created_at: zod.z.string(),
6007
6009
  updated_at: zod.z.string()
6008
6010
  }).meta({ id: "Note" });
6011
+ var noteFolderSchema = zod.z.object({
6012
+ /** Public resourceId of the folder. */
6013
+ id: zod.z.string(),
6014
+ /** Parent folder's resourceId, or null at the box root. */
6015
+ parent_id: zod.z.string().nullable(),
6016
+ name: zod.z.string(),
6017
+ created_at: zod.z.string(),
6018
+ updated_at: zod.z.string()
6019
+ }).meta({ id: "NoteFolder" });
6020
+ var noteTreeSchema = zod.z.object({
6021
+ folders: zod.z.array(noteFolderSchema),
6022
+ notes: zod.z.array(noteSchema)
6023
+ }).meta({ id: "NoteTree" });
6024
+ var noteTrashEntrySchema = zod.z.object({
6025
+ /** "note", "folder", or "box". */
6026
+ kind: zod.z.string(),
6027
+ /** Public resourceId of the trashed root. */
6028
+ id: zod.z.string(),
6029
+ /** Owning box resourceId (null for a box entry). */
6030
+ note_box_id: zod.z.string().nullable(),
6031
+ /** Note title / folder name / box name. */
6032
+ name: zod.z.string(),
6033
+ /** Location hint (box name for notes/folders). */
6034
+ path: zod.z.string().nullable(),
6035
+ child_count: zod.z.number().int(),
6036
+ trashed_at: zod.z.string()
6037
+ }).meta({ id: "NoteTrashEntry" });
6038
+ var noteImportResultSchema = zod.z.object({
6039
+ imported_notes: zod.z.number().int(),
6040
+ created_folders: zod.z.number().int(),
6041
+ skipped: zod.z.number().int()
6042
+ }).meta({ id: "NoteImportResult" });
6009
6043
  var noteHitSchema = zod.z.object({
6010
6044
  id: zod.z.string(),
6011
6045
  title: zod.z.string(),
@@ -6086,6 +6120,47 @@ var noteRenameRequestSchema = zod.z.object({
6086
6120
  retarget_wikilinks: zod.z.coerce.boolean().optional()
6087
6121
  });
6088
6122
  var noteRenameResponseSchema = zod.z.object({ note: noteSchema, retargeted_count: zod.z.number().int() }).meta({ id: "NoteRenameResult" });
6123
+ var folderCreateRequestSchema = zod.z.object({
6124
+ name: zod.z.string().min(1).max(100),
6125
+ /** Parent folder resourceId (null/omitted = box root). */
6126
+ parent_id: zod.z.string().max(64).nullable().optional()
6127
+ });
6128
+ var folderRenameRequestSchema = zod.z.object({
6129
+ name: zod.z.string().min(1).max(100)
6130
+ });
6131
+ var folderMoveRequestSchema = zod.z.object({
6132
+ /** New parent folder resourceId (null/omitted = box root). */
6133
+ parent_id: zod.z.string().max(64).nullable().optional()
6134
+ });
6135
+ var noteMoveRequestSchema = zod.z.object({
6136
+ /** The note's title (identifies it within the box). */
6137
+ title: zod.z.string().min(1).max(200),
6138
+ /** Destination folder resourceId (null/omitted = box root). */
6139
+ folder_id: zod.z.string().max(64).nullable().optional()
6140
+ });
6141
+ var noteImportRequestSchema = zod.z.object({
6142
+ /** Text files to import; folders are derived from the `/`-separated path. */
6143
+ items: zod.z.array(
6144
+ zod.z.object({
6145
+ /** Relative path incl. filename, e.g. `sub/dir/Readme.md`. */
6146
+ path: zod.z.string().min(1).max(1024),
6147
+ content: zod.z.string().max(262144)
6148
+ })
6149
+ ).min(1).max(5e3)
6150
+ });
6151
+ var trashListRequestSchema = zod.z.object({
6152
+ workspace_id: zod.z.string().max(64).optional()
6153
+ });
6154
+ var trashActionRequestSchema = zod.z.object({
6155
+ /** "note", "folder", or "box". */
6156
+ kind: zod.z.enum(["note", "folder", "box"]),
6157
+ /** The trashed root's public resourceId. */
6158
+ id: zod.z.string().max(64)
6159
+ });
6160
+ var trashEmptyRequestSchema = zod.z.object({
6161
+ workspace_id: zod.z.string().max(64).optional()
6162
+ });
6163
+ var trashCountResponseSchema = zod.z.object({ purged_count: zod.z.number().int() }).meta({ id: "NoteTrashPurgeResult" });
6089
6164
  var notesCommands = [
6090
6165
  cmd({
6091
6166
  resource: "notes",
@@ -6337,6 +6412,167 @@ var notesCommands = [
6337
6412
  responseKind: "single",
6338
6413
  request: noteRenameRequestSchema,
6339
6414
  response: noteRenameResponseSchema
6415
+ }),
6416
+ cmd({
6417
+ resource: "notes",
6418
+ verb: "note-move",
6419
+ method: "POST",
6420
+ path: "/notes/boxes/:id/notes/move",
6421
+ permission: ["notes", "write"],
6422
+ summary: "Move a note into a folder (or the box root).",
6423
+ tags: ["Notes"],
6424
+ errors: [404, 422],
6425
+ responseKind: "single",
6426
+ request: noteMoveRequestSchema,
6427
+ response: noteSchema
6428
+ }),
6429
+ cmd({
6430
+ resource: "notes",
6431
+ verb: "tree",
6432
+ method: "GET",
6433
+ path: "/notes/boxes/:id/tree",
6434
+ permission: ["notes", "read"],
6435
+ summary: "Get a box's full tree (folders + notes) in one call.",
6436
+ tags: ["Notes"],
6437
+ errors: [404],
6438
+ responseKind: "single",
6439
+ response: noteTreeSchema
6440
+ }),
6441
+ cmd({
6442
+ resource: "notes",
6443
+ verb: "folder-list",
6444
+ method: "GET",
6445
+ path: "/notes/boxes/:id/folders",
6446
+ permission: ["notes", "read"],
6447
+ summary: "List a box's folders.",
6448
+ tags: ["Notes"],
6449
+ errors: [404],
6450
+ responseKind: "list",
6451
+ response: noteFolderSchema,
6452
+ columns: [
6453
+ { header: "Name", field: "name" },
6454
+ { header: "ID", field: "id" }
6455
+ ]
6456
+ }),
6457
+ cmd({
6458
+ resource: "notes",
6459
+ verb: "folder-create",
6460
+ method: "POST",
6461
+ path: "/notes/boxes/:id/folders",
6462
+ permission: ["notes", "write"],
6463
+ summary: "Create a folder in a box (optionally under a parent folder).",
6464
+ tags: ["Notes"],
6465
+ errors: [404, 409, 422],
6466
+ responseKind: "created",
6467
+ request: folderCreateRequestSchema,
6468
+ response: noteFolderSchema
6469
+ }),
6470
+ cmd({
6471
+ resource: "notes",
6472
+ verb: "folder-rename",
6473
+ method: "PATCH",
6474
+ path: "/notes/folders/:folderId",
6475
+ permission: ["notes", "write"],
6476
+ summary: "Rename a folder.",
6477
+ tags: ["Notes"],
6478
+ errors: [404, 409, 422],
6479
+ responseKind: "single",
6480
+ request: folderRenameRequestSchema,
6481
+ response: noteFolderSchema
6482
+ }),
6483
+ cmd({
6484
+ resource: "notes",
6485
+ verb: "folder-move",
6486
+ method: "POST",
6487
+ path: "/notes/folders/:folderId/move",
6488
+ permission: ["notes", "write"],
6489
+ summary: "Move a folder under another folder (or the box root).",
6490
+ tags: ["Notes"],
6491
+ errors: [404, 409, 422],
6492
+ responseKind: "single",
6493
+ request: folderMoveRequestSchema,
6494
+ response: noteFolderSchema
6495
+ }),
6496
+ cmd({
6497
+ resource: "notes",
6498
+ verb: "folder-delete",
6499
+ method: "DELETE",
6500
+ path: "/notes/folders/:folderId",
6501
+ permission: ["notes", "write"],
6502
+ summary: "Delete a folder \u2192 moves it and its contents to the trash.",
6503
+ tags: ["Notes"],
6504
+ errors: [404],
6505
+ responseKind: "deleted",
6506
+ response: deletedEnvelopeSchema
6507
+ }),
6508
+ cmd({
6509
+ resource: "notes",
6510
+ verb: "import",
6511
+ method: "POST",
6512
+ path: "/notes/boxes/:id/import",
6513
+ permission: ["notes", "write"],
6514
+ summary: "Import text files into a box, recreating their folder hierarchy. 413 over quota.",
6515
+ tags: ["Notes"],
6516
+ errors: [404, 413, 422],
6517
+ responseKind: "single",
6518
+ request: noteImportRequestSchema,
6519
+ response: noteImportResultSchema
6520
+ }),
6521
+ cmd({
6522
+ resource: "notes",
6523
+ verb: "trash-list",
6524
+ method: "GET",
6525
+ path: "/notes/trash",
6526
+ permission: ["notes", "read"],
6527
+ summary: "List the trashed notes, folders, and boxes in a workspace.",
6528
+ tags: ["Notes"],
6529
+ responseKind: "list",
6530
+ request: trashListRequestSchema,
6531
+ response: noteTrashEntrySchema,
6532
+ argLocation: "query",
6533
+ columns: [
6534
+ { header: "Kind", field: "kind" },
6535
+ { header: "Name", field: "name" }
6536
+ ]
6537
+ }),
6538
+ cmd({
6539
+ resource: "notes",
6540
+ verb: "restore",
6541
+ method: "POST",
6542
+ path: "/notes/trash/restore",
6543
+ permission: ["notes", "write"],
6544
+ summary: "Restore a trashed note, folder, or box.",
6545
+ tags: ["Notes"],
6546
+ errors: [404],
6547
+ responseKind: "deleted",
6548
+ request: trashActionRequestSchema,
6549
+ response: deletedEnvelopeSchema
6550
+ }),
6551
+ cmd({
6552
+ resource: "notes",
6553
+ verb: "purge",
6554
+ method: "POST",
6555
+ path: "/notes/trash/purge",
6556
+ permission: ["notes", "write"],
6557
+ summary: "Permanently delete a trashed note, folder, or box (irreversible).",
6558
+ tags: ["Notes"],
6559
+ errors: [404, 422],
6560
+ responseKind: "deleted",
6561
+ request: trashActionRequestSchema,
6562
+ response: deletedEnvelopeSchema
6563
+ }),
6564
+ cmd({
6565
+ resource: "notes",
6566
+ verb: "trash-empty",
6567
+ method: "DELETE",
6568
+ path: "/notes/trash",
6569
+ permission: ["notes", "write"],
6570
+ summary: "Permanently delete every trashed item in a workspace (irreversible).",
6571
+ tags: ["Notes"],
6572
+ responseKind: "single",
6573
+ request: trashEmptyRequestSchema,
6574
+ response: trashCountResponseSchema,
6575
+ argLocation: "query"
6340
6576
  })
6341
6577
  ];
6342
6578
  var notesPlaybook = {
@@ -6358,6 +6594,14 @@ var notesPlaybook = {
6358
6594
  " references a note. Search BEFORE writing to avoid duplicates.",
6359
6595
  "- After adding a note worth surfacing, update the Index with `notes",
6360
6596
  " index-write` so the map stays accurate. The Index cannot be deleted.",
6597
+ "- Organize with FOLDERS: `notes folder-create --box <box> --name` (optionally",
6598
+ " `--parent-id`), then `notes note-move --box <box> --title --folder-id` to",
6599
+ " place a note. Folders are organizational only \u2014 titles stay unique per box,",
6600
+ " so `[[wikilinks]]` resolve the same regardless of folder. `notes tree` returns",
6601
+ " the whole folders+notes hierarchy in one call.",
6602
+ "- Deleting a note/folder/box moves it to the TRASH (recoverable). `notes",
6603
+ " trash-list` shows trashed roots; `notes restore --kind --id` brings one back;",
6604
+ " `notes purge --kind --id` deletes it forever. Trash auto-purges after 30 days.",
6361
6605
  "- Writes that would exceed your account's Notes size quota fail with 413 \u2014",
6362
6606
  " prune or consolidate notes."
6363
6607
  ].join("\n")
@@ -26382,6 +26626,336 @@ var commandCatalog = [
26382
26626
  422
26383
26627
  ]
26384
26628
  },
26629
+ {
26630
+ "command": "notes folder-create",
26631
+ "resource": "notes",
26632
+ "verb": "folder-create",
26633
+ "summary": "Create a folder in a box (optionally under a parent folder).",
26634
+ "method": "POST",
26635
+ "path": "/notes/boxes/:id/folders",
26636
+ "pathParams": [
26637
+ "id"
26638
+ ],
26639
+ "argLocation": "body",
26640
+ "responseKind": "created",
26641
+ "permission": [
26642
+ "notes",
26643
+ "write"
26644
+ ],
26645
+ "async": false,
26646
+ "inputSchema": {
26647
+ "type": "object",
26648
+ "properties": {
26649
+ "name": {
26650
+ "type": "string",
26651
+ "minLength": 1,
26652
+ "maxLength": 100
26653
+ },
26654
+ "parent_id": {
26655
+ "anyOf": [
26656
+ {
26657
+ "type": "string",
26658
+ "maxLength": 64
26659
+ },
26660
+ {
26661
+ "type": "null"
26662
+ }
26663
+ ]
26664
+ }
26665
+ },
26666
+ "required": [
26667
+ "name"
26668
+ ]
26669
+ },
26670
+ "outputSchema": {
26671
+ "type": "object",
26672
+ "properties": {
26673
+ "id": {
26674
+ "type": "string"
26675
+ },
26676
+ "parent_id": {
26677
+ "anyOf": [
26678
+ {
26679
+ "type": "string"
26680
+ },
26681
+ {
26682
+ "type": "null"
26683
+ }
26684
+ ]
26685
+ },
26686
+ "name": {
26687
+ "type": "string"
26688
+ },
26689
+ "created_at": {
26690
+ "type": "string"
26691
+ },
26692
+ "updated_at": {
26693
+ "type": "string"
26694
+ }
26695
+ },
26696
+ "required": [
26697
+ "id",
26698
+ "parent_id",
26699
+ "name",
26700
+ "created_at",
26701
+ "updated_at"
26702
+ ],
26703
+ "additionalProperties": false
26704
+ },
26705
+ "errors": [
26706
+ 404,
26707
+ 409,
26708
+ 422
26709
+ ]
26710
+ },
26711
+ {
26712
+ "command": "notes folder-delete",
26713
+ "resource": "notes",
26714
+ "verb": "folder-delete",
26715
+ "summary": "Delete a folder \u2192 moves it and its contents to the trash.",
26716
+ "method": "DELETE",
26717
+ "path": "/notes/folders/:folderId",
26718
+ "pathParams": [
26719
+ "folderId"
26720
+ ],
26721
+ "argLocation": "body",
26722
+ "responseKind": "deleted",
26723
+ "permission": [
26724
+ "notes",
26725
+ "write"
26726
+ ],
26727
+ "async": false,
26728
+ "inputSchema": {
26729
+ "type": "object",
26730
+ "properties": {},
26731
+ "additionalProperties": {}
26732
+ },
26733
+ "outputSchema": {
26734
+ "type": "object",
26735
+ "properties": {
26736
+ "deleted": {
26737
+ "type": "boolean",
26738
+ "const": true
26739
+ },
26740
+ "id": {
26741
+ "type": "string"
26742
+ }
26743
+ },
26744
+ "required": [
26745
+ "deleted",
26746
+ "id"
26747
+ ],
26748
+ "additionalProperties": false
26749
+ },
26750
+ "errors": [
26751
+ 404
26752
+ ]
26753
+ },
26754
+ {
26755
+ "command": "notes folder-list",
26756
+ "resource": "notes",
26757
+ "verb": "folder-list",
26758
+ "summary": "List a box's folders.",
26759
+ "method": "GET",
26760
+ "path": "/notes/boxes/:id/folders",
26761
+ "pathParams": [
26762
+ "id"
26763
+ ],
26764
+ "argLocation": "query",
26765
+ "responseKind": "list",
26766
+ "permission": [
26767
+ "notes",
26768
+ "read"
26769
+ ],
26770
+ "async": false,
26771
+ "inputSchema": {
26772
+ "type": "object",
26773
+ "properties": {}
26774
+ },
26775
+ "outputSchema": {
26776
+ "type": "object",
26777
+ "properties": {
26778
+ "id": {
26779
+ "type": "string"
26780
+ },
26781
+ "parent_id": {
26782
+ "anyOf": [
26783
+ {
26784
+ "type": "string"
26785
+ },
26786
+ {
26787
+ "type": "null"
26788
+ }
26789
+ ]
26790
+ },
26791
+ "name": {
26792
+ "type": "string"
26793
+ },
26794
+ "created_at": {
26795
+ "type": "string"
26796
+ },
26797
+ "updated_at": {
26798
+ "type": "string"
26799
+ }
26800
+ },
26801
+ "required": [
26802
+ "id",
26803
+ "parent_id",
26804
+ "name",
26805
+ "created_at",
26806
+ "updated_at"
26807
+ ],
26808
+ "additionalProperties": false
26809
+ },
26810
+ "errors": [
26811
+ 404
26812
+ ]
26813
+ },
26814
+ {
26815
+ "command": "notes folder-move",
26816
+ "resource": "notes",
26817
+ "verb": "folder-move",
26818
+ "summary": "Move a folder under another folder (or the box root).",
26819
+ "method": "POST",
26820
+ "path": "/notes/folders/:folderId/move",
26821
+ "pathParams": [
26822
+ "folderId"
26823
+ ],
26824
+ "argLocation": "body",
26825
+ "responseKind": "single",
26826
+ "permission": [
26827
+ "notes",
26828
+ "write"
26829
+ ],
26830
+ "async": false,
26831
+ "inputSchema": {
26832
+ "type": "object",
26833
+ "properties": {
26834
+ "parent_id": {
26835
+ "anyOf": [
26836
+ {
26837
+ "type": "string",
26838
+ "maxLength": 64
26839
+ },
26840
+ {
26841
+ "type": "null"
26842
+ }
26843
+ ]
26844
+ }
26845
+ }
26846
+ },
26847
+ "outputSchema": {
26848
+ "type": "object",
26849
+ "properties": {
26850
+ "id": {
26851
+ "type": "string"
26852
+ },
26853
+ "parent_id": {
26854
+ "anyOf": [
26855
+ {
26856
+ "type": "string"
26857
+ },
26858
+ {
26859
+ "type": "null"
26860
+ }
26861
+ ]
26862
+ },
26863
+ "name": {
26864
+ "type": "string"
26865
+ },
26866
+ "created_at": {
26867
+ "type": "string"
26868
+ },
26869
+ "updated_at": {
26870
+ "type": "string"
26871
+ }
26872
+ },
26873
+ "required": [
26874
+ "id",
26875
+ "parent_id",
26876
+ "name",
26877
+ "created_at",
26878
+ "updated_at"
26879
+ ],
26880
+ "additionalProperties": false
26881
+ },
26882
+ "errors": [
26883
+ 404,
26884
+ 409,
26885
+ 422
26886
+ ]
26887
+ },
26888
+ {
26889
+ "command": "notes folder-rename",
26890
+ "resource": "notes",
26891
+ "verb": "folder-rename",
26892
+ "summary": "Rename a folder.",
26893
+ "method": "PATCH",
26894
+ "path": "/notes/folders/:folderId",
26895
+ "pathParams": [
26896
+ "folderId"
26897
+ ],
26898
+ "argLocation": "body",
26899
+ "responseKind": "single",
26900
+ "permission": [
26901
+ "notes",
26902
+ "write"
26903
+ ],
26904
+ "async": false,
26905
+ "inputSchema": {
26906
+ "type": "object",
26907
+ "properties": {
26908
+ "name": {
26909
+ "type": "string",
26910
+ "minLength": 1,
26911
+ "maxLength": 100
26912
+ }
26913
+ },
26914
+ "required": [
26915
+ "name"
26916
+ ]
26917
+ },
26918
+ "outputSchema": {
26919
+ "type": "object",
26920
+ "properties": {
26921
+ "id": {
26922
+ "type": "string"
26923
+ },
26924
+ "parent_id": {
26925
+ "anyOf": [
26926
+ {
26927
+ "type": "string"
26928
+ },
26929
+ {
26930
+ "type": "null"
26931
+ }
26932
+ ]
26933
+ },
26934
+ "name": {
26935
+ "type": "string"
26936
+ },
26937
+ "created_at": {
26938
+ "type": "string"
26939
+ },
26940
+ "updated_at": {
26941
+ "type": "string"
26942
+ }
26943
+ },
26944
+ "required": [
26945
+ "id",
26946
+ "parent_id",
26947
+ "name",
26948
+ "created_at",
26949
+ "updated_at"
26950
+ ],
26951
+ "additionalProperties": false
26952
+ },
26953
+ "errors": [
26954
+ 404,
26955
+ 409,
26956
+ 422
26957
+ ]
26958
+ },
26385
26959
  {
26386
26960
  "command": "notes graph",
26387
26961
  "resource": "notes",
@@ -26459,6 +27033,86 @@ var commandCatalog = [
26459
27033
  404
26460
27034
  ]
26461
27035
  },
27036
+ {
27037
+ "command": "notes import",
27038
+ "resource": "notes",
27039
+ "verb": "import",
27040
+ "summary": "Import text files into a box, recreating their folder hierarchy. 413 over quota.",
27041
+ "method": "POST",
27042
+ "path": "/notes/boxes/:id/import",
27043
+ "pathParams": [
27044
+ "id"
27045
+ ],
27046
+ "argLocation": "body",
27047
+ "responseKind": "single",
27048
+ "permission": [
27049
+ "notes",
27050
+ "write"
27051
+ ],
27052
+ "async": false,
27053
+ "inputSchema": {
27054
+ "type": "object",
27055
+ "properties": {
27056
+ "items": {
27057
+ "minItems": 1,
27058
+ "maxItems": 5e3,
27059
+ "type": "array",
27060
+ "items": {
27061
+ "type": "object",
27062
+ "properties": {
27063
+ "path": {
27064
+ "type": "string",
27065
+ "minLength": 1,
27066
+ "maxLength": 1024
27067
+ },
27068
+ "content": {
27069
+ "type": "string",
27070
+ "maxLength": 262144
27071
+ }
27072
+ },
27073
+ "required": [
27074
+ "path",
27075
+ "content"
27076
+ ]
27077
+ }
27078
+ }
27079
+ },
27080
+ "required": [
27081
+ "items"
27082
+ ]
27083
+ },
27084
+ "outputSchema": {
27085
+ "type": "object",
27086
+ "properties": {
27087
+ "imported_notes": {
27088
+ "type": "integer",
27089
+ "minimum": -9007199254740991,
27090
+ "maximum": 9007199254740991
27091
+ },
27092
+ "created_folders": {
27093
+ "type": "integer",
27094
+ "minimum": -9007199254740991,
27095
+ "maximum": 9007199254740991
27096
+ },
27097
+ "skipped": {
27098
+ "type": "integer",
27099
+ "minimum": -9007199254740991,
27100
+ "maximum": 9007199254740991
27101
+ }
27102
+ },
27103
+ "required": [
27104
+ "imported_notes",
27105
+ "created_folders",
27106
+ "skipped"
27107
+ ],
27108
+ "additionalProperties": false
27109
+ },
27110
+ "errors": [
27111
+ 404,
27112
+ 413,
27113
+ 422
27114
+ ]
27115
+ },
26462
27116
  {
26463
27117
  "command": "notes index-read",
26464
27118
  "resource": "notes",
@@ -26486,6 +27140,16 @@ var commandCatalog = [
26486
27140
  "id": {
26487
27141
  "type": "string"
26488
27142
  },
27143
+ "folder_id": {
27144
+ "anyOf": [
27145
+ {
27146
+ "type": "string"
27147
+ },
27148
+ {
27149
+ "type": "null"
27150
+ }
27151
+ ]
27152
+ },
26489
27153
  "title": {
26490
27154
  "type": "string"
26491
27155
  },
@@ -26509,6 +27173,7 @@ var commandCatalog = [
26509
27173
  },
26510
27174
  "required": [
26511
27175
  "id",
27176
+ "folder_id",
26512
27177
  "title",
26513
27178
  "content",
26514
27179
  "kind",
@@ -26557,6 +27222,16 @@ var commandCatalog = [
26557
27222
  "id": {
26558
27223
  "type": "string"
26559
27224
  },
27225
+ "folder_id": {
27226
+ "anyOf": [
27227
+ {
27228
+ "type": "string"
27229
+ },
27230
+ {
27231
+ "type": "null"
27232
+ }
27233
+ ]
27234
+ },
26560
27235
  "title": {
26561
27236
  "type": "string"
26562
27237
  },
@@ -26580,6 +27255,7 @@ var commandCatalog = [
26580
27255
  },
26581
27256
  "required": [
26582
27257
  "id",
27258
+ "folder_id",
26583
27259
  "title",
26584
27260
  "content",
26585
27261
  "kind",
@@ -26695,6 +27371,16 @@ var commandCatalog = [
26695
27371
  "id": {
26696
27372
  "type": "string"
26697
27373
  },
27374
+ "folder_id": {
27375
+ "anyOf": [
27376
+ {
27377
+ "type": "string"
27378
+ },
27379
+ {
27380
+ "type": "null"
27381
+ }
27382
+ ]
27383
+ },
26698
27384
  "title": {
26699
27385
  "type": "string"
26700
27386
  },
@@ -26718,6 +27404,7 @@ var commandCatalog = [
26718
27404
  },
26719
27405
  "required": [
26720
27406
  "id",
27407
+ "folder_id",
26721
27408
  "title",
26722
27409
  "content",
26723
27410
  "kind",
@@ -26731,6 +27418,101 @@ var commandCatalog = [
26731
27418
  404
26732
27419
  ]
26733
27420
  },
27421
+ {
27422
+ "command": "notes note-move",
27423
+ "resource": "notes",
27424
+ "verb": "note-move",
27425
+ "summary": "Move a note into a folder (or the box root).",
27426
+ "method": "POST",
27427
+ "path": "/notes/boxes/:id/notes/move",
27428
+ "pathParams": [
27429
+ "id"
27430
+ ],
27431
+ "argLocation": "body",
27432
+ "responseKind": "single",
27433
+ "permission": [
27434
+ "notes",
27435
+ "write"
27436
+ ],
27437
+ "async": false,
27438
+ "inputSchema": {
27439
+ "type": "object",
27440
+ "properties": {
27441
+ "title": {
27442
+ "type": "string",
27443
+ "minLength": 1,
27444
+ "maxLength": 200
27445
+ },
27446
+ "folder_id": {
27447
+ "anyOf": [
27448
+ {
27449
+ "type": "string",
27450
+ "maxLength": 64
27451
+ },
27452
+ {
27453
+ "type": "null"
27454
+ }
27455
+ ]
27456
+ }
27457
+ },
27458
+ "required": [
27459
+ "title"
27460
+ ]
27461
+ },
27462
+ "outputSchema": {
27463
+ "type": "object",
27464
+ "properties": {
27465
+ "id": {
27466
+ "type": "string"
27467
+ },
27468
+ "folder_id": {
27469
+ "anyOf": [
27470
+ {
27471
+ "type": "string"
27472
+ },
27473
+ {
27474
+ "type": "null"
27475
+ }
27476
+ ]
27477
+ },
27478
+ "title": {
27479
+ "type": "string"
27480
+ },
27481
+ "content": {
27482
+ "type": "string"
27483
+ },
27484
+ "kind": {
27485
+ "type": "string"
27486
+ },
27487
+ "version": {
27488
+ "type": "integer",
27489
+ "minimum": -9007199254740991,
27490
+ "maximum": 9007199254740991
27491
+ },
27492
+ "created_at": {
27493
+ "type": "string"
27494
+ },
27495
+ "updated_at": {
27496
+ "type": "string"
27497
+ }
27498
+ },
27499
+ "required": [
27500
+ "id",
27501
+ "folder_id",
27502
+ "title",
27503
+ "content",
27504
+ "kind",
27505
+ "version",
27506
+ "created_at",
27507
+ "updated_at"
27508
+ ],
27509
+ "additionalProperties": false
27510
+ },
27511
+ "errors": [
27512
+ 404,
27513
+ 422
27514
+ ]
27515
+ },
26734
27516
  {
26735
27517
  "command": "notes note-rename",
26736
27518
  "resource": "notes",
@@ -26794,6 +27576,16 @@ var commandCatalog = [
26794
27576
  "id": {
26795
27577
  "type": "string"
26796
27578
  },
27579
+ "folder_id": {
27580
+ "anyOf": [
27581
+ {
27582
+ "type": "string"
27583
+ },
27584
+ {
27585
+ "type": "null"
27586
+ }
27587
+ ]
27588
+ },
26797
27589
  "title": {
26798
27590
  "type": "string"
26799
27591
  },
@@ -26817,6 +27609,7 @@ var commandCatalog = [
26817
27609
  },
26818
27610
  "required": [
26819
27611
  "id",
27612
+ "folder_id",
26820
27613
  "title",
26821
27614
  "content",
26822
27615
  "kind",
@@ -26834,6 +27627,64 @@ var commandCatalog = [
26834
27627
  422
26835
27628
  ]
26836
27629
  },
27630
+ {
27631
+ "command": "notes purge",
27632
+ "resource": "notes",
27633
+ "verb": "purge",
27634
+ "summary": "Permanently delete a trashed note, folder, or box (irreversible).",
27635
+ "method": "POST",
27636
+ "path": "/notes/trash/purge",
27637
+ "pathParams": [],
27638
+ "argLocation": "body",
27639
+ "responseKind": "deleted",
27640
+ "permission": [
27641
+ "notes",
27642
+ "write"
27643
+ ],
27644
+ "async": false,
27645
+ "inputSchema": {
27646
+ "type": "object",
27647
+ "properties": {
27648
+ "kind": {
27649
+ "type": "string",
27650
+ "enum": [
27651
+ "note",
27652
+ "folder",
27653
+ "box"
27654
+ ]
27655
+ },
27656
+ "id": {
27657
+ "type": "string",
27658
+ "maxLength": 64
27659
+ }
27660
+ },
27661
+ "required": [
27662
+ "kind",
27663
+ "id"
27664
+ ]
27665
+ },
27666
+ "outputSchema": {
27667
+ "type": "object",
27668
+ "properties": {
27669
+ "deleted": {
27670
+ "type": "boolean",
27671
+ "const": true
27672
+ },
27673
+ "id": {
27674
+ "type": "string"
27675
+ }
27676
+ },
27677
+ "required": [
27678
+ "deleted",
27679
+ "id"
27680
+ ],
27681
+ "additionalProperties": false
27682
+ },
27683
+ "errors": [
27684
+ 404,
27685
+ 422
27686
+ ]
27687
+ },
26837
27688
  {
26838
27689
  "command": "notes read",
26839
27690
  "resource": "notes",
@@ -26870,6 +27721,16 @@ var commandCatalog = [
26870
27721
  "id": {
26871
27722
  "type": "string"
26872
27723
  },
27724
+ "folder_id": {
27725
+ "anyOf": [
27726
+ {
27727
+ "type": "string"
27728
+ },
27729
+ {
27730
+ "type": "null"
27731
+ }
27732
+ ]
27733
+ },
26873
27734
  "title": {
26874
27735
  "type": "string"
26875
27736
  },
@@ -26893,6 +27754,7 @@ var commandCatalog = [
26893
27754
  },
26894
27755
  "required": [
26895
27756
  "id",
27757
+ "folder_id",
26896
27758
  "title",
26897
27759
  "content",
26898
27760
  "kind",
@@ -26906,6 +27768,63 @@ var commandCatalog = [
26906
27768
  404
26907
27769
  ]
26908
27770
  },
27771
+ {
27772
+ "command": "notes restore",
27773
+ "resource": "notes",
27774
+ "verb": "restore",
27775
+ "summary": "Restore a trashed note, folder, or box.",
27776
+ "method": "POST",
27777
+ "path": "/notes/trash/restore",
27778
+ "pathParams": [],
27779
+ "argLocation": "body",
27780
+ "responseKind": "deleted",
27781
+ "permission": [
27782
+ "notes",
27783
+ "write"
27784
+ ],
27785
+ "async": false,
27786
+ "inputSchema": {
27787
+ "type": "object",
27788
+ "properties": {
27789
+ "kind": {
27790
+ "type": "string",
27791
+ "enum": [
27792
+ "note",
27793
+ "folder",
27794
+ "box"
27795
+ ]
27796
+ },
27797
+ "id": {
27798
+ "type": "string",
27799
+ "maxLength": 64
27800
+ }
27801
+ },
27802
+ "required": [
27803
+ "kind",
27804
+ "id"
27805
+ ]
27806
+ },
27807
+ "outputSchema": {
27808
+ "type": "object",
27809
+ "properties": {
27810
+ "deleted": {
27811
+ "type": "boolean",
27812
+ "const": true
27813
+ },
27814
+ "id": {
27815
+ "type": "string"
27816
+ }
27817
+ },
27818
+ "required": [
27819
+ "deleted",
27820
+ "id"
27821
+ ],
27822
+ "additionalProperties": false
27823
+ },
27824
+ "errors": [
27825
+ 404
27826
+ ]
27827
+ },
26909
27828
  {
26910
27829
  "command": "notes search",
26911
27830
  "resource": "notes",
@@ -27179,6 +28098,255 @@ var commandCatalog = [
27179
28098
  422
27180
28099
  ]
27181
28100
  },
28101
+ {
28102
+ "command": "notes trash-empty",
28103
+ "resource": "notes",
28104
+ "verb": "trash-empty",
28105
+ "summary": "Permanently delete every trashed item in a workspace (irreversible).",
28106
+ "method": "DELETE",
28107
+ "path": "/notes/trash",
28108
+ "pathParams": [],
28109
+ "argLocation": "query",
28110
+ "responseKind": "single",
28111
+ "permission": [
28112
+ "notes",
28113
+ "write"
28114
+ ],
28115
+ "async": false,
28116
+ "inputSchema": {
28117
+ "type": "object",
28118
+ "properties": {
28119
+ "workspace_id": {
28120
+ "type": "string",
28121
+ "maxLength": 64
28122
+ }
28123
+ }
28124
+ },
28125
+ "outputSchema": {
28126
+ "type": "object",
28127
+ "properties": {
28128
+ "purged_count": {
28129
+ "type": "integer",
28130
+ "minimum": -9007199254740991,
28131
+ "maximum": 9007199254740991
28132
+ }
28133
+ },
28134
+ "required": [
28135
+ "purged_count"
28136
+ ],
28137
+ "additionalProperties": false
28138
+ }
28139
+ },
28140
+ {
28141
+ "command": "notes trash-list",
28142
+ "resource": "notes",
28143
+ "verb": "trash-list",
28144
+ "summary": "List the trashed notes, folders, and boxes in a workspace.",
28145
+ "method": "GET",
28146
+ "path": "/notes/trash",
28147
+ "pathParams": [],
28148
+ "argLocation": "query",
28149
+ "responseKind": "list",
28150
+ "permission": [
28151
+ "notes",
28152
+ "read"
28153
+ ],
28154
+ "async": false,
28155
+ "inputSchema": {
28156
+ "type": "object",
28157
+ "properties": {
28158
+ "workspace_id": {
28159
+ "type": "string",
28160
+ "maxLength": 64
28161
+ }
28162
+ }
28163
+ },
28164
+ "outputSchema": {
28165
+ "type": "object",
28166
+ "properties": {
28167
+ "kind": {
28168
+ "type": "string"
28169
+ },
28170
+ "id": {
28171
+ "type": "string"
28172
+ },
28173
+ "note_box_id": {
28174
+ "anyOf": [
28175
+ {
28176
+ "type": "string"
28177
+ },
28178
+ {
28179
+ "type": "null"
28180
+ }
28181
+ ]
28182
+ },
28183
+ "name": {
28184
+ "type": "string"
28185
+ },
28186
+ "path": {
28187
+ "anyOf": [
28188
+ {
28189
+ "type": "string"
28190
+ },
28191
+ {
28192
+ "type": "null"
28193
+ }
28194
+ ]
28195
+ },
28196
+ "child_count": {
28197
+ "type": "integer",
28198
+ "minimum": -9007199254740991,
28199
+ "maximum": 9007199254740991
28200
+ },
28201
+ "trashed_at": {
28202
+ "type": "string"
28203
+ }
28204
+ },
28205
+ "required": [
28206
+ "kind",
28207
+ "id",
28208
+ "note_box_id",
28209
+ "name",
28210
+ "path",
28211
+ "child_count",
28212
+ "trashed_at"
28213
+ ],
28214
+ "additionalProperties": false
28215
+ }
28216
+ },
28217
+ {
28218
+ "command": "notes tree",
28219
+ "resource": "notes",
28220
+ "verb": "tree",
28221
+ "summary": "Get a box's full tree (folders + notes) in one call.",
28222
+ "method": "GET",
28223
+ "path": "/notes/boxes/:id/tree",
28224
+ "pathParams": [
28225
+ "id"
28226
+ ],
28227
+ "argLocation": "query",
28228
+ "responseKind": "single",
28229
+ "permission": [
28230
+ "notes",
28231
+ "read"
28232
+ ],
28233
+ "async": false,
28234
+ "inputSchema": {
28235
+ "type": "object",
28236
+ "properties": {}
28237
+ },
28238
+ "outputSchema": {
28239
+ "type": "object",
28240
+ "properties": {
28241
+ "folders": {
28242
+ "type": "array",
28243
+ "items": {
28244
+ "$ref": "#/$defs/NoteFolder"
28245
+ }
28246
+ },
28247
+ "notes": {
28248
+ "type": "array",
28249
+ "items": {
28250
+ "$ref": "#/$defs/Note"
28251
+ }
28252
+ }
28253
+ },
28254
+ "required": [
28255
+ "folders",
28256
+ "notes"
28257
+ ],
28258
+ "additionalProperties": false,
28259
+ "$defs": {
28260
+ "NoteFolder": {
28261
+ "type": "object",
28262
+ "properties": {
28263
+ "id": {
28264
+ "type": "string"
28265
+ },
28266
+ "parent_id": {
28267
+ "anyOf": [
28268
+ {
28269
+ "type": "string"
28270
+ },
28271
+ {
28272
+ "type": "null"
28273
+ }
28274
+ ]
28275
+ },
28276
+ "name": {
28277
+ "type": "string"
28278
+ },
28279
+ "created_at": {
28280
+ "type": "string"
28281
+ },
28282
+ "updated_at": {
28283
+ "type": "string"
28284
+ }
28285
+ },
28286
+ "required": [
28287
+ "id",
28288
+ "parent_id",
28289
+ "name",
28290
+ "created_at",
28291
+ "updated_at"
28292
+ ],
28293
+ "additionalProperties": false
28294
+ },
28295
+ "Note": {
28296
+ "type": "object",
28297
+ "properties": {
28298
+ "id": {
28299
+ "type": "string"
28300
+ },
28301
+ "folder_id": {
28302
+ "anyOf": [
28303
+ {
28304
+ "type": "string"
28305
+ },
28306
+ {
28307
+ "type": "null"
28308
+ }
28309
+ ]
28310
+ },
28311
+ "title": {
28312
+ "type": "string"
28313
+ },
28314
+ "content": {
28315
+ "type": "string"
28316
+ },
28317
+ "kind": {
28318
+ "type": "string"
28319
+ },
28320
+ "version": {
28321
+ "type": "integer",
28322
+ "minimum": -9007199254740991,
28323
+ "maximum": 9007199254740991
28324
+ },
28325
+ "created_at": {
28326
+ "type": "string"
28327
+ },
28328
+ "updated_at": {
28329
+ "type": "string"
28330
+ }
28331
+ },
28332
+ "required": [
28333
+ "id",
28334
+ "folder_id",
28335
+ "title",
28336
+ "content",
28337
+ "kind",
28338
+ "version",
28339
+ "created_at",
28340
+ "updated_at"
28341
+ ],
28342
+ "additionalProperties": false
28343
+ }
28344
+ }
28345
+ },
28346
+ "errors": [
28347
+ 404
28348
+ ]
28349
+ },
27182
28350
  {
27183
28351
  "command": "notes write",
27184
28352
  "resource": "notes",
@@ -27225,6 +28393,16 @@ var commandCatalog = [
27225
28393
  "id": {
27226
28394
  "type": "string"
27227
28395
  },
28396
+ "folder_id": {
28397
+ "anyOf": [
28398
+ {
28399
+ "type": "string"
28400
+ },
28401
+ {
28402
+ "type": "null"
28403
+ }
28404
+ ]
28405
+ },
27228
28406
  "title": {
27229
28407
  "type": "string"
27230
28408
  },
@@ -27248,6 +28426,7 @@ var commandCatalog = [
27248
28426
  },
27249
28427
  "required": [
27250
28428
  "id",
28429
+ "folder_id",
27251
28430
  "title",
27252
28431
  "content",
27253
28432
  "kind",
@@ -45461,6 +46640,11 @@ function mapArgsToV1(path, pathParams, args) {
45461
46640
  delete out.content;
45462
46641
  delete out.path;
45463
46642
  }
46643
+ if (path === "drive create-folder" && out.name === void 0 && typeof out.path === "string") {
46644
+ const target = out.path;
46645
+ out.name = target.split("/").pop() || target;
46646
+ delete out.path;
46647
+ }
45464
46648
  const resolvedParent = out.resolved_parent_id;
45465
46649
  for (const [from, to] of Object.entries(RESOLVED_FIELD_TO_V1)) {
45466
46650
  const val = out[from];
@@ -45498,6 +46682,13 @@ function mapArgsToV1(path, pathParams, args) {
45498
46682
  }
45499
46683
 
45500
46684
  // src/execute.ts
46685
+ function requestDeclaresWorkspaceId(request) {
46686
+ const shape = request?.shape;
46687
+ return !!shape && Object.hasOwn(shape, "workspace_id");
46688
+ }
46689
+ function hasWorkspaceArg(args) {
46690
+ return args.workspace_id !== void 0 || args.workspace !== void 0;
46691
+ }
45501
46692
  var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
45502
46693
  function isOperationHandle(data) {
45503
46694
  return typeof data === "object" && data !== null && typeof data.id === "string" && typeof data.status === "string";
@@ -45594,10 +46785,11 @@ async function execute(cmd2, opts) {
45594
46785
  rendered: renderInstructions(spec.resource)
45595
46786
  };
45596
46787
  }
46788
+ const mergedArgs = opts.defaultWorkspaceRef && !hasWorkspaceArg(mappedArgs) && requestDeclaresWorkspaceId(spec.request) ? { ...mappedArgs, workspace_id: opts.defaultWorkspaceRef } : mappedArgs;
45597
46789
  return runSpec(
45598
46790
  spec,
45599
46791
  positionals,
45600
- mappedArgs,
46792
+ mergedArgs,
45601
46793
  opts,
45602
46794
  mode,
45603
46795
  opts.background ?? inv.background
@@ -45770,7 +46962,7 @@ function createFetchTransport(opts) {
45770
46962
  }
45771
46963
 
45772
46964
  // src/version.ts
45773
- var VERSION = "1.11.0";
46965
+ var VERSION = "1.12.0";
45774
46966
  var USER_AGENT = `idapt-cli/${VERSION}`;
45775
46967
  var MAX_BUNDLE_FILES = 500;
45776
46968
  var MAX_BUNDLE_FILE_BYTES = 25 * 1024 * 1024;
@@ -47197,6 +48389,113 @@ Automatic update failed (exit ${code}). Run it manually:
47197
48389
  return 0;
47198
48390
  }
47199
48391
 
48392
+ // src/workspace-context.ts
48393
+ function pick(row, ...keys) {
48394
+ for (const k of keys) {
48395
+ const v = row[k];
48396
+ if (typeof v === "string" && v.length > 0) return v;
48397
+ }
48398
+ return void 0;
48399
+ }
48400
+ function qualifiedSlug(row) {
48401
+ const q = pick(row, "qualified_slug", "qualifiedSlug");
48402
+ if (q) return q;
48403
+ const owner = pick(row, "owner_slug", "ownerSlug", "owner");
48404
+ const slug = pick(row, "slug");
48405
+ return owner && slug ? `${owner}/${slug}` : slug;
48406
+ }
48407
+ function resourceIdOf(row) {
48408
+ return pick(row, "resourceId", "resource_id", "id");
48409
+ }
48410
+ function matches(row, ref) {
48411
+ const r = ref.toLowerCase();
48412
+ return [
48413
+ pick(row, "resourceId", "resource_id"),
48414
+ pick(row, "id"),
48415
+ pick(row, "slug"),
48416
+ qualifiedSlug(row)
48417
+ ].some((c) => c !== void 0 && c.toLowerCase() === r);
48418
+ }
48419
+ async function runWorkspaceContext(sub, args, transport, io) {
48420
+ if (sub === "current") {
48421
+ const creds2 = loadCredentials();
48422
+ if (creds2.defaultWorkspaceId) {
48423
+ io.print(`${creds2.defaultWorkspaceSlug ?? creds2.defaultWorkspaceId}
48424
+ `);
48425
+ } else {
48426
+ io.print(
48427
+ "(no default workspace \u2014 scope verbs run in your personal workspace)\n"
48428
+ );
48429
+ }
48430
+ return 0;
48431
+ }
48432
+ if (sub === "clear") {
48433
+ const creds2 = loadCredentials();
48434
+ if (!creds2.defaultWorkspaceId) {
48435
+ io.print("No default workspace was set.\n");
48436
+ return 0;
48437
+ }
48438
+ const was = creds2.defaultWorkspaceSlug ?? creds2.defaultWorkspaceId;
48439
+ creds2.defaultWorkspaceId = void 0;
48440
+ creds2.defaultWorkspaceSlug = void 0;
48441
+ saveCredentials(creds2);
48442
+ io.print(
48443
+ `Cleared the default workspace (was ${was}). Scope verbs now run in your personal workspace.
48444
+ `
48445
+ );
48446
+ return 0;
48447
+ }
48448
+ const ref = args[0];
48449
+ if (!ref) {
48450
+ io.err(
48451
+ "idapt workspace use: missing workspace. Usage: `idapt workspace use <ownerSlug/workspaceSlug | resourceId>`.\n"
48452
+ );
48453
+ return 1;
48454
+ }
48455
+ if (!transport) {
48456
+ io.err("idapt workspace use: not logged in. Run `idapt login` first.\n");
48457
+ return 1;
48458
+ }
48459
+ const listed = await execute("idapt workspace list", {
48460
+ transport,
48461
+ mode: "json"
48462
+ });
48463
+ if (!listed.ok) {
48464
+ io.err(
48465
+ `idapt workspace use: could not list workspaces: ${listed.error ?? "unknown error"}
48466
+ `
48467
+ );
48468
+ return 1;
48469
+ }
48470
+ const rows = Array.isArray(listed.data) ? listed.data : [];
48471
+ const match = rows.find((w) => matches(w, ref));
48472
+ if (!match) {
48473
+ const available = rows.map((w) => ` ${qualifiedSlug(w) ?? resourceIdOf(w) ?? "?"}`).join("\n") || " (none)";
48474
+ io.err(
48475
+ `idapt workspace use: no workspace matches "${ref}". Your workspaces:
48476
+ ${available}
48477
+ `
48478
+ );
48479
+ return 1;
48480
+ }
48481
+ const resourceId = resourceIdOf(match);
48482
+ if (!resourceId) {
48483
+ io.err(
48484
+ "idapt workspace use: the matched workspace is missing a resourceId.\n"
48485
+ );
48486
+ return 1;
48487
+ }
48488
+ const creds = loadCredentials();
48489
+ creds.defaultWorkspaceId = resourceId;
48490
+ creds.defaultWorkspaceSlug = qualifiedSlug(match) ?? resourceId;
48491
+ saveCredentials(creds);
48492
+ io.print(
48493
+ `Default workspace set to ${creds.defaultWorkspaceSlug}. Scope verbs now run there (override per-call with --workspace-id, or run \`idapt workspace clear\`).
48494
+ `
48495
+ );
48496
+ return 0;
48497
+ }
48498
+
47200
48499
  // src/bin.ts
47201
48500
  var DEFAULT_BASE_URL = "https://idapt.app";
47202
48501
  var OUTPUT_MODES = /* @__PURE__ */ new Set(["json", "jsonl", "table", "quiet"]);
@@ -47348,6 +48647,32 @@ async function run(io) {
47348
48647
  rest.slice(1)
47349
48648
  );
47350
48649
  }
48650
+ if (cmd2 === "workspace") {
48651
+ const sub = rest[1];
48652
+ if (sub === "current" || sub === "clear") {
48653
+ return runWorkspaceContext(sub, rest.slice(2), void 0, {
48654
+ print: io.stdout,
48655
+ err: io.stderr
48656
+ });
48657
+ }
48658
+ if (sub === "use") {
48659
+ const wsCred = await resolveCredential({
48660
+ apiKeyFlag,
48661
+ env: io.env,
48662
+ baseUrl,
48663
+ userAgent: USER_AGENT
48664
+ }).catch(() => null);
48665
+ const wsTransport = wsCred ? createFetchTransport({
48666
+ baseUrl,
48667
+ token: wsCred.token,
48668
+ userAgent: USER_AGENT
48669
+ }) : void 0;
48670
+ return runWorkspaceContext(sub, rest.slice(2), wsTransport, {
48671
+ print: io.stdout,
48672
+ err: io.stderr
48673
+ });
48674
+ }
48675
+ }
47351
48676
  const doc = isDocCommand(rest);
47352
48677
  let token;
47353
48678
  const resolved = await resolveCredential({
@@ -47374,9 +48699,11 @@ async function run(io) {
47374
48699
  readFile: (p) => fs.readFileSync(p, "utf-8"),
47375
48700
  readStdin: () => fs.readFileSync(0, "utf-8")
47376
48701
  });
48702
+ const ambientWorkspace = loadCredentials().defaultWorkspaceId;
47377
48703
  const result = await execute(buildCommandFromArgv(restWithJson), {
47378
48704
  transport,
47379
- mode: autoMode(io.isTty, requested)
48705
+ mode: autoMode(io.isTty, requested),
48706
+ ...ambientWorkspace ? { defaultWorkspaceRef: ambientWorkspace } : {}
47380
48707
  });
47381
48708
  if (result.ok) io.stdout(`${result.rendered}
47382
48709
  `);