@davait/aipictury 1.9.2

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 (54) hide show
  1. package/LICENSE.md +77 -0
  2. package/README.md +39 -0
  3. package/ext/about.js +209 -0
  4. package/ext/account.js +242 -0
  5. package/ext/accountUi.js +287 -0
  6. package/ext/agent.js +1929 -0
  7. package/ext/browser.js +263 -0
  8. package/ext/cloud.js +385 -0
  9. package/ext/context.js +241 -0
  10. package/ext/deps.js +142 -0
  11. package/ext/dialogs.js +803 -0
  12. package/ext/diff.js +150 -0
  13. package/ext/extension.js +2483 -0
  14. package/ext/feedback.js +55 -0
  15. package/ext/files.js +565 -0
  16. package/ext/firestore.js +131 -0
  17. package/ext/gpuRun.js +77 -0
  18. package/ext/gpuServer.js +76 -0
  19. package/ext/hooks.js +153 -0
  20. package/ext/log.js +29 -0
  21. package/ext/lsp.js +122 -0
  22. package/ext/mcp.js +469 -0
  23. package/ext/mcpAuth.js +128 -0
  24. package/ext/media/vendor/firebase-config.json +9 -0
  25. package/ext/media/vendor/signin.js +1 -0
  26. package/ext/mediagen.js +174 -0
  27. package/ext/memory.js +117 -0
  28. package/ext/notebook.js +82 -0
  29. package/ext/package.json +1234 -0
  30. package/ext/paths.js +50 -0
  31. package/ext/permissions.js +229 -0
  32. package/ext/plans.js +110 -0
  33. package/ext/plugins.js +243 -0
  34. package/ext/prefs.js +157 -0
  35. package/ext/remote.js +170 -0
  36. package/ext/review.js +126 -0
  37. package/ext/sandbox.js +79 -0
  38. package/ext/scheduler.js +87 -0
  39. package/ext/sessions.js +228 -0
  40. package/ext/sessionsView.js +449 -0
  41. package/ext/shell.js +357 -0
  42. package/ext/storage.js +80 -0
  43. package/ext/tasklist.js +112 -0
  44. package/ext/text.js +31 -0
  45. package/ext/tools.js +781 -0
  46. package/ext/usage.js +77 -0
  47. package/ext/voice.js +135 -0
  48. package/ext/workbench.js +162 -0
  49. package/ext/workflow.js +51 -0
  50. package/ext/worktree.js +83 -0
  51. package/main.js +758 -0
  52. package/package.json +43 -0
  53. package/terminal.js +124 -0
  54. package/vscode-shim.js +231 -0
@@ -0,0 +1,82 @@
1
+ 'use strict'
2
+ // Running a Jupyter cell for the agent, as Claude Code does: the user is asked first (Execute /
3
+ // Cancel), then the cell runs through VS Code's own notebook execution — the kernel the user
4
+ // chose for the notebook — and its outputs come back: text, results, errors. A notebook with
5
+ // no kernel says so.
6
+ const vscode = require('vscode')
7
+ const { resolve } = require('./paths')
8
+
9
+ const decode = (bytes) => new TextDecoder().decode(bytes)
10
+
11
+ /** A cell's outputs as text for the model: stdout, results, errors (pictures are named, not sent). */
12
+ function outputsText(cell) {
13
+ const parts = []
14
+ for (const out of cell.outputs || []) {
15
+ for (const item of out.items || []) {
16
+ if (item.mime === 'application/vnd.code.notebook.error') {
17
+ const e = JSON.parse(decode(item.data))
18
+ parts.push(`Error: ${e.name}: ${e.message}${e.stack ? `\n${e.stack}` : ''}`)
19
+ } else if (/^(text\/|application\/vnd\.code\.notebook\.std)/.test(item.mime) || item.mime === 'application/json') {
20
+ parts.push(decode(item.data))
21
+ } else {
22
+ parts.push(`[${item.mime} output]`)
23
+ }
24
+ }
25
+ }
26
+ return parts.join('\n').trim()
27
+ }
28
+
29
+ /** Which cell: by its notebook id, else by its position. */
30
+ function findCell(doc, id) {
31
+ const all = doc.getCells()
32
+ const byId = all.findIndex((c) => String(c.metadata?.id ?? c.metadata?.metadata?.id ?? '') === String(id))
33
+ if (byId !== -1) return byId
34
+ const n = Number(id)
35
+ if (Number.isInteger(n) && n >= 0 && n < all.length) return n
36
+ throw new Error(`no cell ${id} in this notebook (it has ${all.length})`)
37
+ }
38
+
39
+ /**
40
+ * Runs one code cell. `ask(question, code)` says yes or no (not asked when `skipAsk`).
41
+ * Resolves to the text for the model.
42
+ */
43
+ async function runCell(args, { ask, skipAsk = false, signal, timeoutMs } = {}) {
44
+ const uri = resolve(args.path)
45
+ if (!uri.fsPath.endsWith('.ipynb')) throw new Error('notebook_run_cell runs cells of .ipynb notebooks')
46
+ const doc = await vscode.workspace.openNotebookDocument(uri)
47
+ const index = findCell(doc, args.cell_id ?? 0)
48
+ const cell = doc.cellAt(index)
49
+ if (cell.kind !== vscode.NotebookCellKind.Code) throw new Error(`cell ${index} is Markdown, not code`)
50
+ const code = cell.document.getText()
51
+ if (!skipAsk && !(await ask(`Run cell ${index} of ${args.path}?`, code))) {
52
+ return 'The user chose not to run it. Ask what they want instead, or carry on without its result.'
53
+ }
54
+ await vscode.window.showNotebookDocument(doc, { preserveFocus: true, preview: false })
55
+ const limit = Math.max(5, Math.min(600, Number(args.timeout) || 120)) * 1000
56
+ const before = cell.executionSummary?.executionOrder
57
+ const finished = new Promise((done) => {
58
+ const sub = vscode.workspace.onDidChangeNotebookDocument((e) => {
59
+ if (e.notebook !== doc) return
60
+ for (const change of e.cellChanges) {
61
+ const s = change.cell.index === index && (change.executionSummary || change.cell.executionSummary)
62
+ if (s && s.success !== undefined && s.executionOrder !== before) { sub.dispose(); done(change.cell) }
63
+ }
64
+ })
65
+ signal?.addEventListener('abort', () => { sub.dispose(); done(null) }, { once: true })
66
+ setTimeout(() => { sub.dispose(); done(null) }, timeoutMs ?? limit)
67
+ })
68
+ // Not awaited: with no kernel chosen, VS Code opens its kernel picker and the command waits
69
+ // on it — the result (or the time limit) is what is waited for.
70
+ Promise.resolve(vscode.commands.executeCommand('notebook.cell.execute', { ranges: [{ start: index, end: index + 1 }], document: uri })).catch(() => {})
71
+ const ran = await finished
72
+ if (!ran) vscode.commands.executeCommand('workbench.action.closeQuickOpen').then(() => {}, () => {})
73
+ if (signal?.aborted) return 'stopped by the user'
74
+ if (!ran) {
75
+ return `Cell ${index} did not finish within ${Math.round((timeoutMs ?? limit) / 1000)} s — still running, or no kernel is selected for `
76
+ + 'this notebook (the user picks one at the top right of the notebook).'
77
+ }
78
+ const text = outputsText(ran)
79
+ return `Cell ${index} ran ${ran.executionSummary.success ? 'without errors' : 'with an error'}${text ? `:\n${text}` : ' (no output).'}`
80
+ }
81
+
82
+ module.exports = { runCell, outputsText, findCell }